Part Number Hot Search : 
RLZ20B D74LV 1060C DZ11B AVF30007 MBT2222 5945B WU204
Product Description
Full Text Search
 

To Download C8051F326 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  full speed usb, 16 kb flash mcu family C8051F326/7 rev. 0.5 1/06copyright ? 2006 by silicon laboratoriesC8051F326/7 this information applies to a product under development. its characteristics and specifications are subject to change without notice. usb function controller - usb specification 2.0 compliant - full speed (12mbps) or low speed (1.5mbps) operation - integrated clock recovery; no external crystal required for full speed or low speed - supports three fixed-function endpoints - 256 byte usb buffer memory - integrated transceiver; no external resistors required on-chip debug - on-chip debug circuitry facilitates full speed, non-intrusive in-system debug (no emulator required) - provides breakpoints, single stepping, inspect/modify memory and registers - superior performance to emulation systems using ice-chips, target pods, and sockets voltage supply input: 2.7 to 5.25v - voltages from 3.6 to 5.25v supported using on-chip voltage regulator high speed 8051 c core - pipelined instruction architecture; executes 70% of instructions in 1 or 2system clocks - up to 25mips throughput with 25mhz clock - expanded interrupt handler memory - 1536bytes internal ram (1k + 256 + 256 usb fifo) - 16k bytes flash; in-system programmable in 512-byte sectors digital peripherals - 15 port i/o; all 5v tolerant with high sink current - enhanced uart - two general purpose 16-bit timers clock sources - internal oscillator: 0.25% accuracy with clock recovery enabled. supports all usb and uart modes - external cmos clock - can switch between clock sources on-the-fly; useful in power saving strategies packages - 28-pin qfn - temperature range: C 40 to +85 c analog peripherals 16 kb isp flash 1536 b sram por debug circuitry 8 interrupts 8051 cpu (25mips) digital i/o precision internal oscillator high-speed controller core usb controller / transceiver vreg port 0 port 2 port 3 uart timer 0 timer 1 low frequency oscillator
C8051F326/7 2rev. 0.5 n otes :
rev. 0.53 C8051F326/7 table of contents 1.system overview....................................................................................................13 1.1.cip-51 ? microcontroller core..........................................................................16 1.1.1.fully 8051 compatible..............................................................................16 1.1.2.improved throughput...............................................................................16 1.1.3.additional features..................................................................................17 1.2.on-chip memory...............................................................................................18 1.3.universal serial bus controller.........................................................................19 1.4.voltage regulator.............................................................................................19 1.5.on-chip debug circuitry...................................................................................20 1.6.programmable digital i/o..................................................................................21 1.7.serial ports.......................................................................................................21 2.absolute maximum ratings..................................................................................22 3.global dc electrical characteristics....................................................................23 4.pinout and package definitions............................................................................24 5.voltage regulator (reg0)......................................................................................33 5.1.regulator mode selection.................................................................................33 5.2.vbus detection................................................................................................33 6.cip-51 microcontroller ..........................................................................................37 6.1.instruction set...................................................................................................38 6.1.1.instruction and cpu timing.....................................................................38 6.1.2.movx instruction and program memory.................................................39 6.2.memory organization........................................................................................43 6.2.1.program memory......................................................................................43 6.2.2.data memory............................................................................................44 6.2.3.general purpose registers......................................................................44 6.2.4.bit addressable locations........................................................................44 6.2.5.stack.......................................................................................................44 6.2.6.special function registers.......................................................................45 6.2.7.register descriptions...............................................................................47 6.3.interrupt handler...............................................................................................50 6.3.1.mcu interrupt sources and vectors........................................................50 6.3.2.external interrupts....................................................................................51 6.3.3.interrupt priorities.....................................................................................51 6.3.4.interrupt latency......................................................................................51 6.3.5.interrupt register descriptions.................................................................52 6.4.power management modes..............................................................................57 6.4.1.idle mode..................................................................................................57 6.4.2.stop mode................................................................................................57 7.reset sources .......................................................................................................59 7.1.power-on reset...............................................................................................60 7.2.power-fail reset / vdd monitor.......................................................................61 7.3.external reset..................................................................................................62 7.4.missing clock detector reset...........................................................................62
C8051F326/7 4rev. 0.5 7.5.flash error reset..............................................................................................62 7.6.software reset.................................................................................................62 7.7.usb reset........................................................................................................62 8.flash memory .......................................................................................................65 8.1.programming the flash memory.....................................................................65 8.1.1.flash lock and key functions.................................................................65 8.1.2.flash erase procedure.............................................................................65 8.1.3.flash write procedure..............................................................................66 8.2.non-volatile data storage.................................................................................67 8.3.security options................................................................................................67 9.external ram ........................................................................................................71 9.1.accessing user xram......................................................................................71 9.2.accessing usb fifo space.............................................................................72 10.oscillators...............................................................................................................73 10.1.programmable internal oscillator.....................................................................73 10.1.1.adjusting the internal oscillator on C8051F326/7 devices......................74 10.1.2.internal oscillator suspend mode............................................................74 10.2.internal low-frequency (l-f) oscillator...........................................................76 10.3.4x clock multiplier............................................................................................77 10.4.system and usb clock selection....................................................................78 10.4.1.system clock selection...........................................................................78 10.4.2.usb clock selection................................................................................78 11.port input/output ..................................................................................................81 11.1.port i/o initialization.........................................................................................83 11.2.general purpose port i/o.................................................................................83 12.universal serial bus controller (usb0)................................................................89 12.1.endpoint addressing........................................................................................90 12.2.usb transceiver..............................................................................................90 12.3.usb register access.......................................................................................92 12.4.usb clock configuration..................................................................................96 12.5.fifo management...........................................................................................97 12.5.1.fifo split mode.......................................................................................97 12.5.2.fifo double buffering.............................................................................97 12.5.3.fifo access............................................................................................98 12.6.function addressing.........................................................................................99 12.7.function configuration and control................................................................100 12.8.interrupts........................................................................................................103 12.9.the serial interface engine............................................................................106 12.10.endpoint0.....................................................................................................106 12.10.1.endpoint0 setup transactions..........................................................106 12.10.2.endpoint0 in transactions...................................................................107 12.10.3.endpoint0 out transactions...............................................................107 12.11.configuring endpoint1..................................................................................110 12.12.controlling endpoint1 in...............................................................................110 12.12.1.endpoint1 in interrupt or bulk mode....................................................110
rev. 0.55 C8051F326/7 12.12.2.endpoint1 in isochronous mode..........................................................110 12.13.controlling endpoint1 out...........................................................................114 12.13.1.endpoint1 out interrupt or bulk mode................................................114 12.13.2.endpoint1 out isochronous mode......................................................114 13.uart0....................................................................................................................119 13.1.baud rate generator.....................................................................................120 13.2.data format....................................................................................................122 13.3.configuration and operation..........................................................................123 13.3.1.data transmission.................................................................................123 13.3.2.data reception......................................................................................123 13.3.3.multiprocessor communications............................................................124 14.timers ...................................................................................................................129 14.1.timer 0 and timer 1 operating modes...........................................................129 14.1.1.mode 0: 13-bit timer..............................................................................130 14.1.2.mode 1: 16-bit timer..............................................................................131 14.1.3.mode 2: 8-bit timer with auto-reload....................................................131 14.1.4.mode 3: two 8-bit timers (timer 0 only)..............................................132 15.c2 interface...........................................................................................................137 15.1.c2 interface registers....................................................................................137 15.2.c2 pin sharing...............................................................................................139 contact information.................................................................................................. 140
C8051F326/7 6rev. 0.5 n otes :
rev. 0.57 C8051F326/7 list of figures 1.system overview figure 1.1. C8051F326 block diagram....................................................................14 figure 1.2. c8051f327 block diagram....................................................................15 figure 1.3. comparison of peak mcu execution speeds.......................................16 figure 1.4. on-chip clock and reset......................................................................17 figure 1.5. on-board memory map..........................................................................18 figure 1.6. usb controller block diagram...............................................................19 figure 1.7. development/in-system debug diagram...............................................20 2.absolute maximum ratings 3.global dc electrical characteristics 4.pinout and package definitions figure 4.1. C8051F326 qfn-28 pinout diagram (top view)..................................26 figure 4.2. c8051f327 qfn-28 pinout diagram (top view)..................................27 figure 4.3. qfn-28 package drawing.....................................................................28 figure 4.4. typical C8051F326 qfn-28 landing diagram......................................29 figure 4.5. typical c8051f327 qfn-28 landing diagram......................................30 figure 4.6. typical qfn-28 solder paste recommendation...................................31 5.voltage regulator (reg0) figure 5.1. reg0 configuration: usb bus-powered...............................................34 figure 5.2. reg0 configuration: usb self-powered...............................................34 figure 5.3. reg0 configuration: usb self-powered, regulator disabled..............35 figure 5.4. reg0 configuration: no usb connection.............................................35 6.cip-51 microcontroller figure 6.1. cip-51 block diagram............................................................................37 figure 6.2. memory map..........................................................................................43 7.reset sources figure 7.1. reset sources........................................................................................59 figure 7.2. power-on and vdd monitor reset timing............................................60 8.flash memory figure 8.1. flash program memory map and security byte....................................68 9.external ram figure 9.1. external ram memory map...................................................................71 figure 9.2. xram memory map expanded view.....................................................72 10.oscillators figure 10.1. oscillator diagram................................................................................73 11.port input/output figure 11.1. port i/o functional block diagram.......................................................81 figure 11.2. port i/o cell block diagram.................................................................82 12.universal serial bus controller (usb0) figure 12.1. usb0 block diagram............................................................................89 figure 12.2. usb0 register access scheme...........................................................92 figure 12.3. usb fifo allocation............................................................................97
C8051F326/7 8rev. 0.5 13.uart0 figure 13.1. uart0 block diagram.......................................................................119 figure 13.2. uart0 timing without parity or extra bit..........................................122 figure 13.3. uart0 timing with parity.................................................................122 figure 13.4. uart0 timing with extra bit.............................................................122 figure 13.5. typical uart interconnect diagram..................................................123 figure 13.6. uart multi-processor mode interconnect diagram..........................124 14.timers figure 14.1. t0 mode 0 block diagram..................................................................130 figure 14.2. t0 mode 2 block diagram..................................................................131 figure 14.3. t0 mode 3 block diagram..................................................................132 15.c2 interface figure 15.1. typical c2 pin sharing.......................................................................139
rev. 0.59 C8051F326/7 list of tables 1.system overview table 1.1. product selection guide .........................................................................13 2.absolute maximum ratings table 2.1. absolute maximum ratings ....................................................................22 3.global dc electrical characteristics table 3.1. global dc electrical characteristics .......................................................23 4.pinout and package definitions table 4.1. pin definitions for the C8051F326/7 .......................................................24 table 4.2. qfn-28 package dimensions ................................................................28 5.voltage regulator (reg0) table 5.1. voltage regulator electrical specifications ............................................33 6.cip-51 microcontroller table 6.1. cip-51 instruction set summary ............................................................39 table 6.2. special function register (sfr) memory map ......................................45 table 6.3. special function registers .....................................................................45 table 6.4. interrupt summary ..................................................................................52 7.reset sources table 7.1. reset electrical characteristics ..............................................................64 8.flash memory table 8.1. flash electrical characteristics ..............................................................66 9.external ram 10.oscillators table 10.1. typical usb full speed clock settings ................................................78 table 10.2. typical usb low speed clock settings ...............................................78 table 10.3. internal oscillator electrical characteristics .........................................80 11.port input/output table 11.1. port i/o dc electrical characteristics (C8051F326) ............................87 table 11.2. port i/o dc electrical characteristics (c8051f327) ............................87 12.universal serial bus controller (usb0) table 12.1. endpoint addressing scheme ..............................................................90 table 12.2. usb0 controller registers ...................................................................95 table 12.3. fifo configurations .............................................................................97 table 12.4. usb transceiver electrical characteristics ........................................117 13.uart0 table 13.1. baud rate generator settings for standard baud rates ...................121 14.timers 15.c2 interface
C8051F326/7 10rev. 0.5 n otes :
rev. 0.511 C8051F326/7 list of registers sfr definition 5.1. reg0cn: voltage regulator control . . . . . . . . . . . . . . . . . . . . . .36 sfr definition 6.1. dpl: data pointer low byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47 sfr definition 6.2. dph: data pointer high byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47 sfr definition 6.3. sp: stack pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47 sfr definition 6.4. psw: program status word . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48 sfr definition 6.5. acc: accumulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48 sfr definition 6.6. b: b register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49 sfr definition 6.7. ie: interrupt enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53 sfr definition 6.8. ip: interrupt priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .54 sfr definition 6.9. eie1: extended interrupt enable 1 . . . . . . . . . . . . . . . . . . . . . . . .55 sfr definition 6.10. eip1: extended interrupt priority 1 . . . . . . . . . . . . . . . . . . . . . . .55 sfr definition 6.11. eie2: extended interrupt enable 2 . . . . . . . . . . . . . . . . . . . . . . .55 sfr definition 6.12. eip2: extended interrupt priority 2 . . . . . . . . . . . . . . . . . . . . . . .56 sfr definition 6.13. pcon: power control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58 sfr definition 7.1. vdm0cn: vdd monitor control . . . . . . . . . . . . . . . . . . . . . . . . . .61 sfr definition 7.2. rstsrc: reset source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63 sfr definition 8.1. psctl: program store r/w control . . . . . . . . . . . . . . . . . . . . . . .68 sfr definition 8.2. flkey: flash lock and key . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69 sfr definition 8.3. flscl: flash scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69 sfr definition 9.1. emi0cn: external memory interface control . . . . . . . . . . . . . . . .72 sfr definition 10.1. oscicn: internal oscillator control . . . . . . . . . . . . . . . . . . . . . .74 sfr definition 10.2. oscicl: internal oscillator calibration . . . . . . . . . . . . . . . . . . . .75 sfr definition 10.3. osclcn: internal l-f oscillator control . . . . . . . . . . . . . . . . . . .76 sfr definition 10.4. clkmul: clock multiplier control . . . . . . . . . . . . . . . . . . . . . . . .77 sfr definition 10.5. clksel: clock select . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79 sfr definition 11.1. gpiocn: global port i/o control . . . . . . . . . . . . . . . . . . . . . . . .84 sfr definition 11.2. p0: port0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84 sfr definition 11.3. p0mdout: port0 output mode . . . . . . . . . . . . . . . . . . . . . . . . . .84 sfr definition 11.4. p2: port2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .85 sfr definition 11.5. p2mdout: port2 output mode . . . . . . . . . . . . . . . . . . . . . . . . . .85 sfr definition 11.6. p3: port3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .85 sfr definition 11.7. p3mdout: port3 output mode . . . . . . . . . . . . . . . . . . . . . . . . . .86 usb register definition 12.1. usb0xcn: usb0 transceiver control . . . . . . . . . . . . .91 usb register definition 12.2. usb0adr: usb0 indirect address . . . . . . . . . . . . . . . .93 usb register definition 12.3. usb0dat: usb0 data . . . . . . . . . . . . . . . . . . . . . . . . .94 usb register definition 12.4. index: usb0 endpoint index . . . . . . . . . . . . . . . . . . . .94 usb register definition 12.5. clkrec: clock recovery control . . . . . . . . . . . . . . . .96 usb register definition 12.6. fifon: usb0 endpoint fifo access . . . . . . . . . . . . . .98 usb register definition 12.7. faddr: usb0 function address . . . . . . . . . . . . . . . . .99 usb register definition 12.8. power: usb0 power . . . . . . . . . . . . . . . . . . . . . . . .101 usb register definition 12.9. framel: usb0 frame number low . . . . . . . . . . . . .102 usb register definition 12.10. frameh: usb0 frame number high . . . . . . . . . . .102 usb register definition 12.11. in1int: usb0 in endpoint interrupt . . . . . . . . . . . . .103
C8051F326/7 12rev. 0.5 usb register definition 12.12. out1int: usb0 out endpoint interrupt . . . . . . . . . .103 usb register definition 12.13. cmint: usb0 common interrupt . . . . . . . . . . . . . . .104 usb register definition 12.14. in1ie: usb0 in endpoint interrupt enable . . . . . . . .104 usb register definition 12.15. out1ie: usb0 out endpoint interrupt enable . . . . .105 usb register definition 12.16. cmie: usb0 common interrupt enable . . . . . . . . . .105 usb register definition 12.17. e0csr: usb0 endpoint0 control . . . . . . . . . . . . . . .108 usb register definition 12.18. e0cnt: usb0 endpoint 0 data count . . . . . . . . . . .109 usb register definition 12.19. eincsrl: usb0 in endpoint control low byte . . . .112 usb register definition 12.20. eincsrh: usb0 in endpoint control high byte . . .113 usb register definition 12.21. eoutcsrl: usb0 out endpoint control low byte 115 usb register definition 12.22. eoutcsrh: usb0 out endpoint control high byte 116 usb register definition 12.23. eoutcntl: usb0 out endpoint count low . . . . .116 usb register definition 12.24. eoutcnth: usb0 out endpoint count high . . . .116 sfr definition 13.1. scon0: uart0 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125 sfr definition 13.2. smod0: uart0 mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126 sfr definition 13.3. sbuf0: uart0 data buffer . . . . . . . . . . . . . . . . . . . . . . . . . . .127 sfr definition 13.4. sbcon0: uart0 baud rate generator control . . . . . . . . . . .127 sfr definition 13.5. sbrlh0: uart0 baud rate generator high byte . . . . . . . . . .128 sfr definition 13.6. sbrll0: uart0 baud rate generator low byte . . . . . . . . . . .128 sfr definition 14.1. tcon: timer control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133 sfr definition 14.2. tmod: timer mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134 sfr definition 14.3. ckcon: clock control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .135 sfr definition 14.4. tl0: timer 0 low byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136 sfr definition 14.5. tl1: timer 1 low byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136 sfr definition 14.6. th0: timer 0 high byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136 sfr definition 14.7. th1: timer 1 high byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136 c2 register definition 15.1. c2add: c2 address . . . . . . . . . . . . . . . . . . . . . . . . . . .137 c2 register definition 15.2. deviceid: c2 device id . . . . . . . . . . . . . . . . . . . . . . . .137 c2 register definition 15.3. revid: c2 revision id . . . . . . . . . . . . . . . . . . . . . . . . .138 c2 register definition 15.4. fpctl: c2 flash programming control . . . . . . . . . . . .138 c2 register definition 15.5. fpdat: c2 flash programming data . . . . . . . . . . . . . .138
rev. 0.513 C8051F326/7 1.system overview C8051F326/7 devices are fully integrated mixed-signal system-on-a-chip mcus. highlighted features are listed below. refer to table1.1 for specific product feature selection. ? high-speed pipelined 8051-compatible microcontroller core (up to 25mips) ? in-system, full-speed, non-intrusive debug interface (on-chip) ? universal serial bus (usb) function controller with three fixed-function endpoint pipes, integrated trans- ceiver, and 256bfifo ram ? supply voltage regulator ? precision programmable 12mhz internal oscillator and 4x clock multiplier ? 16 kb of on-chip flash memory ? 1536 total bytes of on-chip ram (256 + 1k + 256 usb fifo) ? enhanced uart, serial interfaces implemented in hardware ? two general-purpose 16-bit timers ? on-chip power-on reset, vdd monitor, and missing clock detector ? 15 port i/o (5v tolerant) with on-chip power-on reset, vdd monitor, voltage regulator, and clock oscillator, C8051F326/7 devices are truly stand-alone system-on-a-chip solutions. the flash memory can be reprogrammed in-circuit, pro- viding non-volatile data storage, and also allowing field upgrades of the 8051 firmware. user software has complete control of all peripherals, and may individually shut down any or all peripherals for power sav- ings. the on-chip silicon laboratories 2-wire (c2) development interface allows non-intrusive (uses no on-chip resources), full speed, in-circuit debugging using the production mcu installed in the final application. this debug logic supports inspection and modification of memory and registers, setting breakpoints, single stepping, run and halt commands. all analog and digital peripherals are fully functional while debugging using c2. the two c2 interface pins can be shared with user functions, allowing in-system debugging with- out occupying package pins. each device is specified for 2.7 C 5.25v operation over the industrial temperature range ( C 40 to +85 c). for voltages above 3.6v, the on-chip voltage regulator must be used. a minimum of 3.0 v is required for usb communication. the port i/o and rst pins are tolerant of input signals up to 5v. C8051F326/7 are available in two 28-pin qfn packages with different pinouts. the rohs compliant devices are marked with a -gq suffix in the part number. the port i/o on C8051F326 devices is powered from a separate i/o supply allowing it to interface to low voltage logic. table1.1.product selection guide o r d e r i n g p a r t n u m b e r m i p s ( p e a k ) f l a s h m e m o r y r a m c a l i b r a t e d i n t e r n a l o s c i l l a t o r u s b s u p p l y v o l t a g e r e g u l a t o r u a r t t i m e r s ( 1 6 - b i t ) d i g i t a l p o r t i / o s s e p a r a t e i / o s u p p l y p a c k a g e C8051F326 25 161536 2 15 qfn-28 C8051F326-gq 25 161536 2 15 qfn-28 c8051f327 25 161536 2 15 qfn-28 c8051f327-gq 25 161536 2 15 qfn-28
C8051F326/7 14rev. 0.5 figure 1.1. C8051F326 block diagram uart 16 kb flash 256 byte sram por sfr bus 8 0 5 1 c o r e reset /rst/c2ck debug hw brown- out p 0 d r v 1 kb xram xtal2 p0.0/sysclk p0.1 p0.2 p0.3/xtal2 p0.4/tx p0.5/rx p0.6 p0.7 regin port 0 latch timer 0,1 system clock p 2 d r v p 3 d r v p2.0 p2.1 p2.2 p2.3 p2.4 p2.5 p3.0/c2d c2d port 2 latch port 3 latch usb controller usb transceiver analog/digital power voltage regulator 5.0 v 256 byte usb sram vbus d+ d- 12 mhz internal oscillator gnd vdd in out enable x4 2 usb clock 2 clock recovery /sysclk low freq oscillator xtal2 1,2,3,4 vio
rev. 0.515 C8051F326/7 figure 1.2. c8051f327 block diagram uart 16 kb flash 256 byte sram por sfr bus 8 0 5 1 c o r e reset /rst/c2ck debug hw brown- out p 0 d r v 1 kb xram xtal2 p0.0/sysclk p0.1 p0.2 p0.3/xtal2 p0.4/tx p0.5/rx p0.6 p0.7 regin port 0 latch timer 0,1 system clock p 2 d r v p 3 d r v p2.0 p2.1 p2.2 p2.3 p2.4 p2.5 p3.0/c2d c2d port 2 latch port 3 latch usb controller usb transceiver analog/digital power voltage regulator 5.0 v 256 byte usb sram vbus d+ d- 12 mhz internal oscillator gnd vdd in out enable x4 2 usb clock 2 clock recovery /sysclk low freq oscillator xtal2 1,2,3,4
C8051F326/7 16rev. 0.5 1.1.cip-51 ? microcontroller core 1.1.1.fully 8051 compatible the C8051F326/7 family utilizes silicon laboratories' proprietary cip-51 microcontroller core. the cip-51 is fully compatible with the mcs-51 ? instruction set; standard 803x/805x assemblers and compilers can be used to develop software. the cip-51 core offers all the peripherals included with a standard 8052, including two 16-bit counter/timers, a full-duplex uart with extended baud rate configuration, 1536bytes of on-chip ram, 128byte special function register (sfr) address space, and 15 i/o pins. 1.1.2.improved throughput the cip-51 employs a pipelined architecture that greatly increases its instruction throughput over the stan- dard 8051 architecture. in a standard 8051, all instructions except for mul and div take 12 or 24 system clock cycles to execute with a maximum system clock of 12-to-24mhz. by contrast, the cip-51 core exe- cutes 70% of its instructions in one or two system clock cycles, with only four instructions taking more than four system clock cycles. the cip-51 has a total of 109 instructions. the table below shows the total number of instructions that require each execution time. with the cip-51's maximum system clock at 25mhz, it has a peak throughput of 25mips. figure1.3 shows a comparison of peak throughputs for various 8-bit microcontroller cores with their maximum sys- tem clocks. figure 1.3. comparison of peak mcu execution speeds clocks to execute 1 2 2/3 3 3/4 4 4/5 5 8 number of instructions 26 50 5 14 7 3 1 2 1 5 10 15 20 aduc812 8051 (16 mhz clk) philips 80c51 (33 mhz clk) microchip pic17c75x (33 mhz clk) silicon labs cip-51 (25 mhz clk) m i p s 25
rev. 0.517 C8051F326/7 1.1.3.additional features the C8051F326/7 soc family includes several key enhancements to the cip-51 core and peripherals to improve performance and ease of use in end applications. the extended interrupt handler provides 8interrupt sources into the cip-51. an interrupt driven system requires less intervention by the mcu, giving it more effective throughput. the interrupt sources are very useful when building multi-tasking, real-time systems. seven reset sources are available: power-on reset circuitry (por), an on-chip vdd monitor (forces reset when power supply voltage drops below v rst as given in table7.1 on page64), the usb controller (usb bus reset or a vbus transition), a missing clock detector, a forced software reset, an external reset pin, and an errant flash read/write protection circuit. each reset source except for the por, reset input pin, or flash error may be disabled by the user in software. the internal oscillator is factory calibrated to 12mhz 1.5%, and the internal oscillator period may be user programmed in ~0.25% increments. an additional low-frequency oscillator is also available which facili- tates low power operation. a clock recovery mechanism allows the internal oscillator to be used with the 4x clock multiplier as the usb clock source in full speed mode; the internal oscillator can also be used as the usb clock source in low speed mode. an external cmos clock may also be used with the 4x clock multiplier. the system clock may be configured to use the internal oscillator, external clock, low-frequency oscillator, or the clock multiplier output divided by 2. if desired, the system clock source may be switched on-the-fly between oscillator sources. the external clock and internal low-frequency oscillator can be extremely useful in low power applications, allowing the mcu to run from a slow (power saving) clock source, while periodically switching to the high-frequency internal oscillator as needed. figure 1.4. on-chip clock and reset missing clock detector (one- shot) (software reset) system reset reset funnel en swrsf internal oscillator system clock cip-51 microcontroller core extended interrupt handler clock select m c d e n a b l e xtal2 external clock input errant flash operation /rst (wired-or) power on reset + - vdd supply monitor enable '0' low frequency oscillator
C8051F326/7 18rev. 0.5 1.2.on-chip memory the cip-51 has a standard 8051 program and data address configuration. it includes 256 bytes of data ram, with the upper 128 bytes dual-mapped. indirect addressing accesses the upper 128 bytes of general purpose ram, and direct addressing accesses the 128 byte sfr address space. the lower 128 bytes of ram are accessible via direct and indirect addressing. the first 32 bytes are addressable as four banks of general purpose registers, and the next 16 bytes can be byte addressable or bit addressable. program memory consists of 16 bytes of flash. this memory may be reprogrammed in-system in 512 byte sectors, and requires no special off-chip programming voltage. see figure1.5 for the mcu system mem- ory map. figure 1.5. on-board memory map same 1024 bytes as from 0x0000 to 0x03ff, wrapped on 1k-byte boundaries program/data memory (flash) (direct and indirect addressing) 0x00 0x7f upper 128 ram (indirect addressing only) 0x80 0xff special function register's (direct addressing only) data memory (ram) general purpose registers 0x1f 0x20 0x2f bit addressable lower 128 ram (direct and indirect addressing) 0x30 internal data address space external data address space xram - 1024 bytes (accessable using movx instruction) 0x0000 0x03ff 0x0400 0xffff 16k flash (in-system programmable in 512 byte sectors) 0x0000 reserved 0x3e00 0x3dff usb fifos 256 bytes accessible through usb registers only 0x3fff
rev. 0.519 C8051F326/7 1.3.universal serial bus controller the universal serial bus controller (usb0) is a usb 2.0 peripheral with integrated transceiver and end- point fifo ram. the controller supports both full and low speed modes. a total of three endpoint pipes are available: a bi-directional control endpoint (endpoint0) and a data endpoint (endpoint1) with one in pipe and one out pipe. a 256 block of xram is used as dedicated usb fifo space. this fifo space is distributed between endpoint0 and endpoint1. endpoint0 is 64 bytes, and endpoint1 has a 64 byte in pipe and a 128 byte out pipe. usb0 can be operated as a full or low speed function. the on-chip 4x clock multiplier and clock recovery circuitry allow both full and low speed options to be implemented with the on-chip precision oscillator as the usb clock source. an external clock source can also be used with the 4x clock multiplier to generate the usb clock. the usb transceiver is usb 2.0 compliant, and includes on-chip matching and pullup resistors. the pul- lup resistors can be enabled/disabled in software, and will appear on the d+ or d C pin according to the software-selected speed setting (full or low speed). figure 1.6. usb controller block diagram 1.4.voltage regulator C8051F326/7 devices include a voltage regulator (reg0). when enabled, the reg0 output appears on the vdd pin and can be used to power external devices. reg0 can be enabled/disabled by software. transceiver serial interface engine (sie) usb fifos (256b ram) d+ d- vdd endpoint0 in/out endpoint1 in out data transfer control cip-51 core usb control, status, and interrupt registers
C8051F326/7 20rev. 0.5 1.5.on-chip debug circuitry C8051F326/7 devices include on-chip silicon laboratories 2-wire (c2) debug circuitry that provides non- intrusive, full speed, in-circuit debugging of the production part installed in the end application. the silicon laboratories' debugging system supports inspection and modification of memory and registers, breakpoints, and single stepping. no additional target ram, program memory, timers, or communications channels are required. all the digital and analog peripherals are functional and work correctly while debug- ging. all the peripherals (except for the usb) are stalled when the mcu is halted, during single stepping, or at a breakpoint in order to keep them synchronized. the C8051F326dk development kit provides all the hardware and software necessary to develop applica- tion code and perform in-circuit debugging with the C8051F326/7 mcus. the kit includes a windows development environment, a serial adapter for connecting to the c2 port, and a target application board. all of the necessary communication cables and a wall-mount power supply are also supplied with the development kit. the silicon laboratories debug environment is a vastly superior configuration for devel- oping and debugging embedded applications compared to standard mcu emulators, which use on-board "ice chips" and target cables and require the mcu in the application board to be socketed. the silicon laboratories debug environment enhances ease of use and preserves the performance of on-chip periph- erals. figure 1.7. development/in-system debug diagram target pcb serial adapter vddgnd c2 (x2), vdd, gnd windows pc silicon laboratories integrated development environment C8051F326
rev. 0.521 C8051F326/7 1.6.programmable digital i/o C8051F326/7 devices include 15 i/o pins (one byte-wide port, one 6-bit-wide and one 1-bit-wide port). the C8051F326/7 ports behave like typical 8051 ports with a few enhancements. each port pin may be configured as a digital input or output pin. pins selected as digital outputs may additionally be configured for push-pull or open-drain output. the weak pullups that are fixed on typical 8051 devices may be glo- bally disabled, providing power savings capabilities. 1.7.serial ports the C8051F326/7 family includes a full-duplex uart with enhanced baud rate configuration. the serial interface is fully implemented in hardware and makes extensive use of the cip-51's interrupts, thus requir- ing very little cpu intervention.
C8051F326/7 22rev. 0.5 2.absolute maximum ratings table2.1.absolute maximum ratings parameterconditionsmintypmaxunits ambient temperature under bias C 55 125 c storage temperature C 65 150 c voltage on any port i/o pin or rst with respect to gnd C 0.3 5.8v voltage on vdd or vio with respect to gnd C 0.3 4.2v maximum total current through vdd, vio, and gnd 500ma maximum output current sunk by rst or any port pin 100ma note: stresses above those listed under absolute maximum ratings may cause permanent damage to the device. this is a stress rating only and functional operation of the devices at those or any other conditions above those indicated in the operation listings of this specification is not implied. exposure to maximum rating conditions for extended periods may affect device reliability.
rev. 0.523 C8051F326/7 3.global dc electrical characteristics table3.1.global dc electrical characteristics C 40 to +85 c, 25mhz system clock unless otherwise specified. parameter conditions min typ max units i/o supply voltage (vio) 1,2 1.83.33.6v core supply voltage (vdd) 3 2.73.33.6v core supply current with cpu active vdd = 3.3 v, clock = 24 mhz vdd = 3.3 v, clock = 3 mhz vdd = 3.3 v, clock = 32 khz 11 1.9 20 ma ma a core supply current with cpu active and usb active (full or low speed) vdd = 3.3 v, clock = 24 mhz vdd = 3.3 v, clock = 6 mhz tbd tbd ma ma core supply current with cpu inactive (not accessing flash) vdd = 3.3 v, clock = 24 mhz vdd = 3.3 v, clock = 3 mhz vdd = 3.3 v, clock = 32 khz 4.4 0.83 13 ma ma a digital supply current (sus- pend mode or shutdown mode) oscillator not running < 0.1 a digital supply ram data reten- tion voltage 1.5 v sysclk (system clock) 4 0 25mhz t sysh (sysclk high time)18 ns t sysl (sysclk low time)18 ns specified operating tempera- ture range C 40 +85 c notes: 1. the i/o supply voltage (vio) must be less than or equal to the core supply voltage (vdd). 2. for c8051f327 devices, vio is internally connected to vdd. 3. usb requires 3.0v minimum core supply voltage (vdd). 4. sysclk must be at least 32 khz to enable debugging.
C8051F326/7 24rev. 0.5 4.pinout and package definitions table4.1.pin definitions for the C8051F326/7 name pin numbers type description f326 f327 vdd 6 6 power in power out 2.7 C 3.6v core supply voltage input. 3.3v voltage regulator output. see section 5 . vio 5 power in v i/o supply voltage input. the voltage at this pin must be less than or equal to the core supply voltage (v dd ) for the 'f326. on the 'f327, this pin is internally connected to v dd . gnd 2 3 ground. rst / c2ck 9 9 d i/o d i/o device reset. open-drain output of internal por or vdd monitor. an external source can initiate a system reset by driving this pin low for at least 15 s. see section 7 . clock signal for the c2 debug interface. p3.0/ c2d 10 10 d i/o d i/o port 3.0. see section 11 for a complete description. bi-directional data signal for the c2 debug interface. regin 7 7 power in 5v regulator input. this pin is the input to the on-chip volt- age regulator. vbus 8 8 d in vbus sense input. this pin should be connected to the vbus signal of a usb network. a 5v signal on this pin indi- cates a usb network connection. d+ 3 4 d i/ousb d+. d C 4 5 d i/ousb d C . p0.0 1 2 d i/oport 0.0. see section 11 for a complete description. p0.1 28 1 d i/oport 0.1. see section 11 for a complete description. p0.2 27 28 d i/oport 0.2. see section 11 for a complete description. p0.3/ xtal2 26 27 d i/o d in port 0.3. see section 11 for a complete description. external clock input. see section 10 for a complete description. p0.4 25 26 d i/oport 0.4. see section 11 for a complete description. p0.5 24 25 d i/oport 0.5. see section 11 for a complete description.
rev. 0.525 C8051F326/7 p0.6 23 24 d i/oport 0.6. see section 11 for a complete description. p0.7 22 23 d i/oport 0.7. see section 11 for a complete description. p2.0 19 19 d i/oport 2.0. see section 11 for a complete description. p2.1 18 18 d i/oport 2.1. see section 11 for a complete description. p2.2 12 12 d i/oport 2.2. see section 11 for a complete description. p2.3 11 11 d i/oport 2.3. see section 11 for a complete description. p2.4 17 17 d i/oport 2.4. see section 11 for a complete description. p2.5 16 16 d i/oport 2.5. see section 11 for a complete description. n.c. pins for the f326: 13, 14, 15, 20, and 21. n.c. pins for the f327: 13, 14, 15, 20, 21, and 22. table 4.1. pin definitions for the C8051F326/7 (continued) name pin numbers type description f326 f327
C8051F326/7 26rev. 0.5 figure 4.1. C8051F326 qfn-28 pinout diagram (top view) 4 5 6 7 2 1 3 1 1 1 2 1 3 1 4 9 8 1 0 18 17 16 15 20 21 19 2 5 2 6 2 7 2 8 2 3 2 2 2 4 C8051F326 top view p0.0 gnd d+ d- vio vdd regin v b u s / r s t / c 2 c k p 3 . 0 / c 2 d p 2 . 3 p 2 . 2 n . c . n . c . n.c. p2.5 p2.4 p2.1 p2.0 n.c. n.c. p 0 . 7 p 0 . 6 p 0 . 5 p 0 . 4 p 0 . 3 p 0 . 2 p 0 . 1 gnd gnd
rev. 0.527 C8051F326/7 figure 4.2. c8051f327 qfn-28 pinout diagram (top view) 4 5 6 7 2 1 3 1 1 1 2 1 3 1 4 9 8 1 0 18 17 16 15 20 21 19 2 5 2 6 2 7 2 8 2 3 2 2 2 4 c8051f327 top view p0.1 p0.0 gnd d+ d- vdd regin v b u s / r s t / c 2 c k p 3 . 0 / c 2 d p 2 . 3 p 2 . 2 n . c . n . c . n.c. p2.5 p2.4 p2.1 p2.0 n.c. n.c. n . c . p 0 . 7 p 0 . 6 p 0 . 5 p 0 . 4 p 0 . 3 p 0 . 2 gnd gnd
C8051F326/7 28rev. 0.5 figure 4.3. qfn-28 package drawing 1 d e r l bottom view side view 2 3 4 5 6 7 21 20 19 17 16 15 d2 18 d2 2 6 x e detail 1 detail 1 aa cc table 4.2. qfn-28 package dimensions mm mintypmax a0.800.901.00 a100.020.05 a200.651.00 a3-0.25- b0.180.230.30 d-5.00- d22.903.153.35 e-5.00- e22.903.153.35 e-0.5- l0.450.550.65 n-28- nd-7- ne-7- r0.09-- aa-0.435- bb-0.435- cc-0.18- dd-0.18-
rev. 0.529 C8051F326/7 figure 4.4. typical C8051F326 qfn-28 landing diagram optional gnd connection b l 0.50 mm 0.30 mm 0.10 mm 0.20 mm 0.85 mm 0.35 mm e e d 0 . 5 0 m m 0 . 3 0 m m 0 . 1 0 m m 0 . 2 0 m m 0.85 mm 0 . 3 5 m m top view e2 d 2 0 . 2 0 m m 0.20 mm 0 . 5 0 m m 0.50 mm
C8051F326/7 30rev. 0.5 figure 4.5. typical c8051f327 qfn-28 landing diagram optional gnd connection b l 0.50 mm 0.30 mm 0.10 mm 0.20 mm 0.85 mm 0.35 mm e e d 0 . 5 0 m m 0 . 3 0 m m 0 . 1 0 m m 0 . 2 0 m m 0.85 mm 0 . 3 5 m m top view e2 d 2 0 . 2 0 m m 0.20 mm 0 . 5 0 m m 0.50 mm
rev. 0.531 C8051F326/7 figure 4.6. typical qfn-28 solder paste recommendation l 0.50 mm 0.30 mm 0.10 mm 0.20 mm 0.85 mm 0.35 mm e 0.85 mm top view e2 0.20 mm 0.50 mm 0.30 mm 0.20 mm 0.60 mm 0.40 mm 0.70 mm 0.60 mm
C8051F326/7 32rev. 0.5 n otes :
rev. 0.533 C8051F326/7 5.voltage regulator (reg0) C8051F326/7 devices include a voltage regulator (reg0). when enabled, the reg0 output appears on the vdd pin and can be used to power external devices. reg0 can be enabled/disabled by software using bit regen in register reg0cn. see table5.1 for reg0 electrical characteristics. the voltage regulator is enabled on reset. when the device is self-powered from a 3v supply net, the reg- ulator may be disabled in order to save power. important note: if the voltage at the regulator input (regin) is greater than the core supply voltage (vdd), the voltage regulator should not be dis- abled. otherwise, permanent damage to the device may occur. note that the vbus signal must be connected to the vbus pin when using the device in a usb network. the vbus signal should only be connected to the regin pin when operating the device as a bus-powered function. reg0 configuration options are shown in figure5.1 - figure5.4. 5.1.regulator mode selection reg0 offers a low power mode intended for use when the device is in suspend mode. in this low power mode, the reg0 output remains as specified; however the reg0 dynamic performance (response time) is degraded. see table5.1 for normal and low power mode supply current specifications. the reg0 mode selection is controlled via the regmod bit in register reg0cn. 5.2.vbus detection when the usb function controller is used (see section section 12.universal serial bus controller (usb0) on page89 ), the vbus signal should be connected to the vbus pin. the vbstat bit (register reg0cn) indicates the current logic level of the vbus signal. if enabled, a vbus interrupt will be gener- ated when the vbus signal matches the polarity selected by the vbpol bit in register reg0cn. the vbus interrupt is level-sensitive, and has no associated interrupt pending flag. the vbus interrupt will be active as long as the vbus signal matches the polarity selected by vbpol. see table5.1 for vbus input parameters. important note: when usb is selected as a reset source, a system reset will be generated when the vbus signal matches the polarity selected by the vbpol bit. see section 7.reset sources on page59 for details on selecting usb as a reset source. table5.1.voltage regulator electrical specifications vdd = 3.0v; C 40 to +85 c unless otherwise specified parameter conditions min typ max units input voltage range 2.7 5.25 v output voltage output current = 1 to 100ma 3.0 3.3 3.6 v vbus detection input threshold 1.0 1.8 4.0 v bias current normal mode (regmod = 0 ) low power mode (regmod = 1 ) 75 41 tbd tbd a dropout voltage (v do )* idd=1ma idd=100ma 1 100 mv/ma *note: the minimum input voltage is 2.70v or v dd + v do (max load), whichever is greater.
C8051F326/7 34rev. 0.5 figure 5.1. reg0 configuration: usb bus-powered figure 5.2. reg0 configuration: usb self-powered voltage regulator (reg0) 5 v in 3 v out vbus sense regin vbus from vbus to 3 v power net device power net vdd C8051F326/7 voltage regulator (reg0) 5 v in 3 v out vbus sense regin vbus to 3 v power net device power net vdd C8051F326/7 from 5 v power net from vbus
rev. 0.535 C8051F326/7 figure 5.3. reg0 configuration: usb self-powered, regulator disabled figure 5.4. reg0 configuration: no usb connection voltage regulator (reg0) 5 v in 3 v out vbus sense regin vbus from 3 v power net device power net vdd C8051F326/7 from vbus voltage regulator (reg0) 5v in 3v out vbus sense regin vbus to 3v power net device power net vdd C8051F326/7 from 5v power net
C8051F326/7 36rev. 0.5 sfr definition5.1.reg0cn: voltage regulator control bit7:regdis: voltage regulator disable. 0: voltage regulator enabled. 1: voltage regulator disabled. bit6:vbstat: vbus signal status. 0: vbus signal currently absent (device not attached to usb network). 1: vbus signal currently present (device attached to usb network). bit5: vbpol: vbus interrupt polarity select. this bit selects the vbus interrupt polarity. 0: vbus interrupt active when vbus is low. 1: vbus interrupt active when vbus is high. bit4:regmod: voltage regulator mode select. this bit selects the voltage regulator mode. when regmod is set to 1 , the voltage regu- lator operates in low power (suspend) mode. 0: usb0 voltage regulator in normal mode. 1: usb0 voltage regulator in low power mode. bits3 C 0: reserved. read = 0000b. must write = 0000b. r/wrr/wr/wr/wr/wr/wr/wreset value regdisvbstatvbpolregmodreservedreservedreservedreserved00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0xc9
rev. 0.537 C8051F326/7 6.cip-51 microcontroller the mcu system controller core is the cip-51 microcontroller. the cip-51 is fully compatible with the mcs-51 ? instruction set; standard 803x/805x assemblers and compilers can be used to develop soft- ware. the mcu family has a superset of all the peripherals included with a standard 8051. included are two 16-bit counter/timers (see description in section 14 ), an enhanced full-duplex uart (see description in section 13 ), 256bytes of internal ram, 128byte special function register (sfr) address space ( sec- tion 6.2.6 ), and 15 port i/o (see description in section 11 ). the cip-51 also includes on-chip debug hard- ware (see description in section 15 ), and interfaces directly with the usb and other digital subsystems providing a complete solution in a single integrated circuit. the cip-51 microcontroller core implements the standard 8051 organization and peripherals as well as additional custom peripherals and functions to extend its capability (see figure6.1 for a block diagram). the cip-51 includes the following features: figure 6.1. cip-51 block diagram -fully compatible with mcs-51 instruction set -25 mips peak throughput with 25 mhz clock -0 to 25 mhz clock frequency -256 bytes of internal ram -15 port i/o -extended interrupt handler -reset input -power management modes -on-chip debug logic -program and data memory security data bus tmp1 tmp2 prgm. address reg. pc incrementer alu psw data bus memory interface mem_address d8 pipeline buffer data pointer interrupt interface system_irqs emulation_irq mem_control control logic a16 program counter (pc) stop clock reset idle power control register sfr bus interface sfr_address sfr_control sfr_write_data sfr_read_data d8 d8 b register d 8 d 8 accumulator d 8 d8 d8 d8 d 8 d 8 d 8 d8 mem_write_data mem_read_data d 8 sram address register sram (256 x 8) d 8 stack pointer d 8
C8051F326/7 38rev. 0.5 performance the cip-51 employs a pipelined architecture that greatly increases its instruction throughput over the stan- dard 8051 architecture. in a standard 8051, all instructions except for mul and div take 12 or 24 system clock cycles to execute, and usually have a maximum system clock of 12mhz. by contrast, the cip-51 core executes 70% of its instructions in one or two system clock cycles, with no instructions taking more than eight system clock cycles. with the cip-51's maximum system clock at 25mhz, it has a peak throughput of 25mips. the cip-51 has a total of 109 instructions. the table below shows the total number of instructions that for execution time. programming and debugging support in-system programming of the flash program memory and communication with on-chip debug support logic is accomplished via the silicon laboratories 2-wire development interface (c2). note that the re-pro- grammable flash can also be read and changed a single byte at a time by the application software using the movc and movx instructions. this feature allows program memory to be used for non-volatile data storage as well as updating program code under software control. the on-chip debug support logic facilitates full speed in-circuit debugging, allowing the setting of hardware breakpoints, starting, stopping and single stepping through program execution (including interrupt service routines), examination of the program's call stack, and reading/writing the contents of registers and mem- ory. this method of on-chip debugging is completely non-intrusive, requiring no ram, stack, timers, or other on-chip resources. c2 details can be found in section 15.c2 interface on page137 . the cip-51 is supported by development tools from silicon laboratories and third party vendors. silicon laboratories provides an integrated development environment (ide) including editor, macro assembler, debugger and programmer. the ide's debugger and programmer interface to the cip-51 via the c2 inter- face to provide fast and efficient in-system device programming and debugging. third party macro assem- blers and c compilers are also available. 6.1.instruction set the instruction set of the cip-51 system controller is fully compatible with the standard mcs-51 ? instruc- tion set. standard 8051 development tools can be used to develop software for the cip-51. all cip-51 instructions are the binary and functional equivalent of their mcs-51 ? counterparts, including opcodes, addressing modes and effect on psw flags. however, instruction timing is different than that of the stan- dard 8051. 6.1.1.instruction and cpu timing in many 8051 implementations, a distinction is made between machine cycles and clock cycles, with machine cycles varying from 2 to 12 clock cycles in length. however, the cip-51 implementation is based solely on clock cycle timing. all instruction timings are specified in terms of clock cycles. due to the pipelined architecture of the cip-51, most instructions execute in the same number of clock cycles as there are program bytes in the instruction. conditional branch instructions take one less clock cycle to complete when the branch is not taken as opposed to when the branch is taken. table6.1 is the cip-51 instruction set summary, which includes the mnemonic, number of bytes, and number of clock cycles for each instruction. clocks to execute 1 2 2/3 3 3/4 4 4/5 5 8 number of instructions 26 50 5 14 7 3 1 2 1
rev. 0.539 C8051F326/7 6.1.2.movx instruction and program memory the movx instruction is typically used to access external data memory (note: the C8051F326/7 does not support off-chip data or program memory). in the cip-51, the movx write instruction is used to accesses external ram (xram) and the on-chip program memory space implemented as re-programmable flash memory. the flash access feature provides a mechanism for the cip-51 to update program code and use the program memory space for non-volatile data storage. refer to section 8.flash memory on page65 for further details. table6.1.cip-51 instruction set summary mnemonic description bytes clock cycles arithmetic operations add a, rn add register to a 1 1 add a, direct add direct byte to a 2 2 add a, @ri add indirect ram to a 1 2 add a, #data add immediate to a 2 2 addc a, rn add register to a with carry 1 1 addc a, direct add direct byte to a with carry 2 2 addc a, @ri add indirect ram to a with carry 1 2 addc a, #data add immediate to a with carry 2 2 subb a, rn subtract register from a with borrow 1 1 subb a, direct subtract direct byte from a with borrow 2 2 subb a, @ri subtract indirect ram from a with borrow 1 2 subb a, #data subtract immediate from a with borrow 2 2 inc a increment a 1 1 inc rn increment register 1 1 inc direct increment direct byte 2 2 inc @ri increment indirect ram 1 2 dec a decrement a 1 1 dec rn decrement register 1 1 dec direct decrement direct byte 2 2 dec @ri decrement indirect ram 1 2 inc dptr increment data pointer 1 1 mul ab multiply a and b 1 4 div ab divide a by b 1 8 da a decimal adjust a 1 1 logical operations anl a, rn and register to a 1 1 anl a, direct and direct byte to a 2 2 anl a, @ri and indirect ram to a 1 2 anl a, #data and immediate to a 2 2 anl direct, a and a to direct byte 2 2 anl direct, #data and immediate to direct byte 3 3 orl a, rn or register to a 1 1 orl a, direct or direct byte to a 2 2 orl a, @ri or indirect ram to a 1 2 orl a, #data or immediate to a 2 2 orl direct, a or a to direct byte 2 2
C8051F326/7 40rev. 0.5 orl direct, #data or immediate to direct byte 3 3 xrl a, rn exclusive-or register to a 1 1 xrl a, direct exclusive-or direct byte to a 2 2 xrl a, @ri exclusive-or indirect ram to a 1 2 xrl a, #data exclusive-or immediate to a 2 2 xrl direct, a exclusive-or a to direct byte 2 2 xrl direct, #data exclusive-or immediate to direct byte 3 3 clr a clear a 1 1 cpl a complement a 1 1 rl a rotate a left 1 1 rlc a rotate a left through carry 1 1 rr a rotate a right 1 1 rrc a rotate a right through carry 1 1 swap a swap nibbles of a 1 1 data transfer mov a, rn move register to a 1 1 mov a, direct move direct byte to a 2 2 mov a, @ri move indirect ram to a 1 2 mov a, #data move immediate to a 2 2 mov rn, a move a to register 1 1 mov rn, direct move direct byte to register 2 2 mov rn, #data move immediate to register 2 2 mov direct, a move a to direct byte 2 2 mov direct, rn move register to direct byte 2 2 mov direct, direct move direct byte to direct byte 3 3 mov direct, @ri move indirect ram to direct byte 2 2 mov direct, #data move immediate to direct byte 3 3 mov @ri, a move a to indirect ram 1 2 mov @ri, direct move direct byte to indirect ram 2 2 mov @ri, #data move immediate to indirect ram 2 2 mov dptr, #data16 load dptr with 16-bit constant 3 3 movc a, @a+dptr move code byte relative dptr to a 1 3 movc a, @a+pc move code byte relative pc to a 1 3 movx a, @ri move external data (8-bit address) to a 1 3 movx @ri, a move a to external data (8-bit address) 1 3 movx a, @dptr move external data (16-bit address) to a 1 3 movx @dptr, a move a to external data (16-bit address) 1 3 push direct push direct byte onto stack 2 2 pop direct pop direct byte from stack 2 2 xch a, rn exchange register with a 1 1 xch a, direct exchange direct byte with a 2 2 xch a, @ri exchange indirect ram with a 1 2 xchd a, @ri exchange low nibble of indirect ram with a 1 2 boolean manipulation clr c clear carry 1 1 table 6.1. cip-51 instruction set summary (continued) mnemonic description bytes clock cycles
rev. 0.541 C8051F326/7 clr bit clear direct bit 2 2 setb c set carry 1 1 setb bit set direct bit 2 2 cpl c complement carry 1 1 cpl bit complement direct bit 2 2 anl c, bit and direct bit to carry 2 2 anl c, /bit and complement of direct bit to carry 2 2 orl c, bit or direct bit to carry 2 2 orl c, /bit or complement of direct bit to carry 2 2 mov c, bit move direct bit to carry 2 2 mov bit, c move carry to direct bit 2 2 jc rel jump if carry is set 2 2/3 jnc rel jump if carry is not set 2 2/3 jb bit, rel jump if direct bit is set 3 3/4 jnb bit, rel jump if direct bit is not set 3 3/4 jbc bit, rel jump if direct bit is set and clear bit 3 3/4 program branching acall addr11 absolute subroutine call 2 3 lcall addr16 long subroutine call 3 4 ret return from subroutine 1 5 reti return from interrupt 1 5 ajmp addr11 absolute jump 2 3 ljmp addr16 long jump 3 4 sjmp rel short jump (relative address) 2 3 jmp @a+dptr jump indirect relative to dptr 1 3 jz rel jump if a equals zero 2 2/3 jnz rel jump if a does not equal zero 2 2/3 cjne a, direct, rel compare direct byte to a and jump if not equal 3 3/4 cjne a, #data, rel compare immediate to a and jump if not equal 3 3/4 cjne rn, #data, rel compare immediate to register and jump if not equal 3 3/4 cjne @ri, #data, rel compare immediate to indirect and jump if not equal 3 4/5 djnz rn, rel decrement register and jump if not zero 2 2/3 djnz direct, rel decrement direct byte and jump if not zero 3 3/4 nop no operation 1 1 table 6.1. cip-51 instruction set summary (continued) mnemonic description bytes clock cycles
C8051F326/7 42rev. 0.5 notes on registers, operands and addressing modes: rn - register r0-r7 of the currently selected register bank. @ri - data ram location addressed indirectly through r0 or r1. rel - 8-bit, signed (2s complement) offset relative to the first byte of the following instruction. used by sjmp and all conditional jumps. direct - 8-bit internal data location s address. this could be a direct-access data ram location (0x00- 0x7f) or an sfr (0x80-0xff). #data - 8-bit constant #data16 - 16-bit constant bit - direct-accessed bit in data ram or sfr addr11 - 11-bit destination address used by acall and ajmp. the destination must be within the same 2 kb page of program memory as the first byte of the following instruction. addr16 - 16-bit destination address used by lcall and ljmp. the destination may be anywhere within the 8 kb program memory space. there is one unused opcode (0xa5) that performs the same function as nop. all mnemonics copyrighted ? intel corporation 1980.
rev. 0.543 C8051F326/7 6.2.memory organization the memory organization of the cip-51 system controller is similar to that of a standard 8051. there are two separate memory spaces: program memory and data memory. program and data memory share the same address space but are accessed via different instruction types. the cip-51 memory organization is shown in figure6.2. figure 6.2. memory map 6.2.1.program memory the cip-51 core has a 64kb program memory space. the C8051F326/7 implements 16 kb of this pro- gram memory space as in-system, re-programmable flash memory, organized in a contiguous block from addresses 0x0000 to 0x3fff. addresses above 0x3dff are reserved. program memory is normally assumed to be read-only. however, the cip-51 can write to program memory by setting the program store write enable bit (psctl.0) and using the movx instruction. this feature pro- vides a mechanism for the cip-51 to update program code and use the program memory space for non- volatile data storage. refer to section 8.flash memory on page65 for further details. same 1024 bytes as from 0x0000 to 0x03ff, wrapped on 1k-byte boundaries program/data memory (flash) (direct and indirect addressing) 0x00 0x7f upper 128 ram (indirect addressing only) 0x80 0xff special function register's (direct addressing only) data memory (ram) general purpose registers 0x1f 0x20 0x2f bit addressable lower 128 ram (direct and indirect addressing) 0x30 internal data address space external data address space xram - 1024 bytes (accessable using movx instruction) 0x0000 0x03ff 0x0400 0xffff 16k flash (in-system programmable in 512 byte sectors) 0x0000 reserved 0x3e00 0x3dff usb fifos 256 bytes accessible through usb registers only 0x3fff
C8051F326/7 44rev. 0.5 6.2.2.data memory the cip-51 includes 256 of internal ram mapped into the data memory space from 0x00 through 0xff. the lower 128bytes of data memory are used for general purpose registers and scratch pad memory. either direct or indirect addressing may be used to access the lower 128bytes of data memory. locations 0x00 through 0x1f are addressable as four banks of general purpose registers, each bank consisting of eight byte-wide registers. the next 16bytes, locations 0x20 through 0x2f, may either be addressed as bytes or as 128bit locations accessible with the direct addressing mode. the upper 128bytes of data memory are accessible only by indirect addressing. this region occupies the same address space as the special function registers (sfr) but is physically separate from the sfr space. the addressing mode used by an instruction when accessing locations above 0x7f determines whether the cpu accesses the upper 128bytes of data memory space or the sfrs. instructions that use direct addressing will access the sfr space. instructions using indirect addressing above 0x7f access the upper 128bytes of data memory. figure6.2 illustrates the data memory organization of the cip-51. 6.2.3.general purpose registers the lower 32 bytes of data memory, locations 0x00 through 0x1f, may be addressed as four banks of gen- eral-purpose registers. each bank consists of eight byte-wide registers designated r0 through r7. only one of these banks may be enabled at a time. two bits in the program status word, rs0 (psw.3) and rs1 (psw.4), select the active register bank (see description of the psw in figure6.4). this allows fast context switching when entering subroutines and interrupt service routines. indirect addressing modes use regis- ters r0 and r1 as index registers. 6.2.4.bit addressable locations in addition to direct access to data memory organized as bytes, the sixteen data memory locations at 0x20 through 0x2f are also accessible as 128individually addressable bits. each bit has a bit address from 0x00 to 0x7f. bit0 of the byte at 0x20 has bit address 0x00 while bit7 of the byte at 0x20 has bit address 0x07. bit 7 of the byte at 0x2f has bit address 0x7f. a bit access is distinguished from a full byte access by the type of instruction used (bit source or destination operands as opposed to a byte source or destina- tion). the mcs-51 ? assembly language allows an alternate notation for bit addressing of the form xx.b where xx is the byte address and b is the bit position within the byte. for example, the instruction: movc, 22h.3 moves the boolean value at 0x13 (bit 3 of the byte at location 0x22) into the carry flag. 6.2.5.stack a programmer's stack can be located anywhere in the 256-byte data memory. the stack area is desig- nated using the stack pointer (sp, 0x81) sfr. the sp will point to the last location used. the next value pushed on the stack is placed at sp+1 and then sp is incremented. a reset initializes the stack pointer to location 0x07. therefore, the first value pushed on the stack is placed at location 0x08, which is also the first register (r0) of register bank 1. thus, if more than one register bank is to be used, the sp should be initialized to a location in the data memory not being used for data storage. the stack depth can extend up to 256bytes.
rev. 0.545 C8051F326/7 6.2.6.special function registers the direct-access data memory locations from 0x80 to 0xff constitute the special function registers (sfrs). the sfrs provide control and data exchange with the cip-51's resources and peripherals. the cip-51 duplicates the sfrs found in a typical 8051 implementation as well as implementing additional sfrs used to configure and access the sub-systems unique to the mcu. this allows the addition of new functionality while retaining compatibility with the mcs-51 ? instruction set. table6.2lists the sfrs imple- mented in the cip-51 system controller. the sfr registers are accessed anytime the direct addressing mode is used to access memory locations from 0x80 to 0xff. sfrs with addresses ending in 0x0 or 0x8 (e.g., p0, tcon, scon0, ie, etc.) are bit- addressable as well as byte-addressable. all other sfrs are byte-addressable only. unoccupied addresses in the sfr space are reserved for future use. accessing these areas will have an indeterminate effect and should be avoided. refer to the corresponding pages of the data sheet, as indicated in table6.3, for a detailed description of each register. table6.2.special function register (sfr) memory map f8 vdm0cn f0 b eip1 eip2 e8 rstsrc e0 acc gpiocnosclcn eie1 eie2 d8 d0 psw usb0xcn c8 reg0cn c0 b8 ip clkmul b0 p3 oscicn oscicl flscl flkey a8 ie clkselemi0cn a0 p2 p0mdout p2mdoutp3mdout 98 scon0 sbuf0 smod0 90 sbcon0 sbrll0 sbrlh0 usb0adrusb0dat 88 tcon tmod tl0 tl1 th0 th1 ckcon psctl 80 p0 sp dpl dph pcon 0(8) 1(9) 2(a) 3(b) 4(c) 5(d) 6(e) 7(f) (bit addressable) table6.3.special function registers sfrs are listed in alphabetical order. all undefined sfr locations are reserved. register address description page acc 0xe0 accumulator 48 b 0xf0 b register 49 ckcon 0x8e clock control 135 clkmul 0x91 clock multiplier 77 clksel 0xa9 clock select 79 dph 0x83 data pointer high 47 dpl 0x82 data pointer low 47
C8051F326/7 46rev. 0.5 eie1 0xe6 extended interrupt enable 1 55 eie2 0xe7 extended interrupt enable 2 55 eip1 0xf6 extended interrupt priority 1 55 eip2 0xf7 extended interrupt priority 2 56 emi0cn 0xaa external memory interface control 72 flkey 0xb7 flash lock and key 69 flscl 0xb6 flash scale 69 gpiocn 0xe2 global port i/o control 84 ie 0xa8 interrupt enable 53 ip 0xb8 interrupt priority 54 oscicl 0xb3 internal oscillator calibration 75 oscicn 0xb2 internal oscillator control 74 osclcn 0xe3 low frequency internal oscillator control 76 p0 0x80 port 0 latch 84 p0mdout 0xa4 port 0 output mode configuration 84 p2 0xa0 port 2 latch 85 p2mdout 0xa6 port 2 output mode configuration 85 p3 0xb0 port 3 latch 85 p3mdout 0xa7 port 3 output mode configuration 86 pcon 0x87 power control 58 psctl 0x8f program store r/w control 68 psw 0xd0 program status word 48 rstsrc 0xef reset source configuration/status 63 sbuf0 0x99 uart0 data buffer 127 sbcon0 0x91 baudrate generator 0 control 127 sbrlh0 0x94 baudrate generator 0 reload value high byte 128 sbrll0 0x93 baudrate generator 0 reload value low byte 128 scon0 0x98 uart0 control 125 smod0 0x9a uart0 mode 126 sp 0x81 stack pointer 47 tcon 0x88 timer/counter control 133 th0 0x8c timer/counter 0 high 136 th1 0x8d timer/counter 1 high 136 tl0 0x8a timer/counter 0 low 136 tl1 0x8b timer/counter 1 low 136 tmod 0x89 timer/counter mode 134 usb0adr 0x96 indirect address register 93 usb0dat 0x97 data register 94 usb0xcn 0xd7 transceiver control 91 vdm0cn 0xff vdd monitor control 61 table 6.3. special function registers (continued) sfrs are listed in alphabetical order. all undefined sfr locations are reserved. register address description page
rev. 0.547 C8051F326/7 6.2.7.register descriptions following are descriptions of sfrs related to the operation of the cip-51 system controller. reserved bits should not be set to logicl. future product versions may use these bits to implement new features in which case the reset value of the bit will be logic0, selecting the feature's default state. detailed descriptions of the remaining sfrs are included in the sections of the data sheet associated with their corresponding sys- tem function. sfr definition6.1.dpl: data pointer low byte sfr definition6.2.dph: data pointer high byte sfr definition6.3.sp: stack pointer bits7 C 0:dpl: data pointer low. the dpl register is the low byte of the 16-bit dptr. dptr is used to access indirectly addressed memory. r/wr/wr/wr/wr/wr/wr/wr/wreset value 00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0x82 bits7 C 0:dph: data pointer high. the dph register is the high byte of the 16-bit dptr. dptr is used to access indirectly addressed memory. r/wr/wr/wr/wr/wr/wr/wr/wreset value 00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0x83 bits7 C 0:sp: stack pointer. the stack pointer holds the location of the top of the stack. the stack pointer is incremented before every push operation. the sp register defaults to 0x07 after reset. r/wr/wr/wr/wr/wr/wr/wr/wreset value 00000111 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0x81
C8051F326/7 48rev. 0.5 sfr definition6.4.psw: program status word sfr definition6.5.acc: accumulator bit7:cy: carry flag. this bit is set when the last arithmetic operation resulted in a carry (addition) or a borrow (subtraction). it is cleared to logic 0 by all other arithmetic operations. bit6:ac: auxiliary carry flag this bit is set when the last arithmetic operation resulted in a carry into (addition) or a borrow from (subtraction) the high order nibble. it is cleared to logic 0 by all other arithmetic opera- tions. bit5:f0: user flag 0. this is a bit-addressable, general purpose flag for use under software control. bits4 C 3:rs1-rs0: register bank select. these bits select which register bank is used during register accesses. bit2:ov: overflow flag. this bit is set to 1 under the following circumstances: ? an add, addc, or subb instruction causes a sign-change overflow. ? a mul instruction results in an overflow (result is greater than 255). ? a div instruction causes a divide-by-zero condition. the ov bit is cleared to 0 by the add, addc, subb, mul, and div instructions in all other cases. bit1:f1: user flag 1. this is a bit-addressable, general purpose flag for use under software control. bit0:parity: parity flag. r/wr/wr/wr/wr/wr/wr/wrreset value cyacf0rs1rs0ovf1parity00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: (bit addressable) 0xd0 rs1rs0register bankaddress 0000x00 C 0x07 0110x08 C 0x0f 1020x10 C 0x17 1130x18 C 0x1f bits7 C 0:acc: accumulator. this register is the accumulator for arithmetic operations. r/wr/wr/wr/wr/wr/wr/wr/wreset value acc.7acc.6acc.5acc.4acc.3acc.2acc.1acc.000000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: (bit addressable) 0xe0
rev. 0.549 C8051F326/7 sfr definition6.6.b: b register bits7 C 0:b: b register. this register serves as a second accumulator for certain arithmetic operations. r/wr/wr/wr/wr/wr/wr/wr/wreset value b.7b.6b.5b.4b.3b.2b.1b.000000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: (bit addressable) 0xf0
C8051F326/7 50rev. 0.5 6.3.interrupt handler the cip-51 includes an extended interrupt system supporting a total of 8interrupt sources with two priority levels. the allocation of interrupt sources between on-chip peripherals and external inputs pins varies according to the specific version of the device. each interrupt source, with the exception of usb0, has one or more associated interrupt-pending flag(s) located in an sfr. usb0 interrupt sources are located in the usb registers. see section 12.8 for more details about the usb interrupt. when a peripheral or external source meets a valid interrupt condition, the associated interrupt-pending flag is set to logic1. if interrupts are enabled for the source, an interrupt request is generated when the interrupt-pending flag is set. as soon as execution of the current instruction is complete, the cpu generates an lcall to a prede- termined address to begin execution of an interrupt service routine (isr). each isr must end with an reti instruction, which returns program execution to the next instruction that would have been executed if the interrupt request had not occurred. if interrupts are not enabled, the interrupt-pending flag is ignored by the hardware and program execution continues as normal. (the interrupt-pending flag is set to logic1 regard- less of the interrupt's enable/disable state.) each interrupt source can be individually enabled or disabled through the use of an associated interrupt enable bit in an sfr (ie-eie2). however, interrupts must first be globally enabled by setting the ea bit (ie.7) to logic1 before the individual interrupt enables are recognized. setting the ea bit to logic 0 disables all interrupt sources regardless of the individual interrupt-enable settings. note: any instruction which clears the ea bit should be immediately followed by an instruction which has two or more opcode bytes. for example: // in 'c': ea = 0; // clear ea bit ea = 0; // ... followed by another 2-byte opcode ; in assembly: clr ea ; clear ea bit clr ea ; ... followed by another 2-byte opcode if an interrupt is posted during the execution phase of a "clr ea" opcode (or any instruction that clears the ea bit), and the instruction is followed by a single-cycle instruction, the interrupt may be taken. if the ea bit is read inside the interrupt service routine, it will return a '0'. when the "clr ea" opcode is followed by a multi-cycle instruction, the interrupt will not be taken. some interrupt-pending flags are automatically cleared by the hardware when the cpu vectors to the isr. however, most are not cleared by the hardware and must be cleared by software before returning from the isr. if an interrupt-pending flag remains set after the cpu completes the return-from-interrupt (reti) instruction, a new interrupt request will be generated immediately and the cpu will re-enter the isr after the completion of the next instruction. 6.3.1.mcu interrupt sources and vectors the mcu supports 8 interrupt sources. software can simulate an interrupt by setting any interrupt-pending flag to logic1. if interrupts are enabled for the flag, an interrupt request will be generated and the cpu will vector to the isr address associated with the interrupt-pending flag. mcu interrupt sources, associated vector addresses, priority order and control bits are summarized in table6.4 on page52. refer to the data sheet section associated with a particular on-chip peripheral for information regarding valid interrupt condi- tions for the peripheral and the behavior of its interrupt-pending flag(s).
rev. 0.551 C8051F326/7 6.3.2.external interrupts the /int0 active low external interrupt source is mapped to p0.0 (or p0.2 when tmod.3 is logic 1) and can be configured as edge or level sensitive. the it0 bit (tcon.0, see figure14.1 on page133) selects level or edge sensitive. when global port i/o inputs are enabled, /int0 will monitor the voltage at the input pin. the cpu will vector to the /int0 interrupt service routine once a falling edge or low signal is detected. the /int1 interrupt source provides an interrupt on two events, based on the logic level of gate1 (tmod.7). if gate1 is set to logic 1, an interrupt is generated every two low frequency internal oscillator clock cycles. this allows the cpu to vector to the /int1 interrupt service routine at a rate of 40khz. if gate1 is set to logic 0, an interrupt is generated when the internal oscillator resumes from a suspended state. the pending flags for the /int0 and /int1 interrupts are set upon reset. if the /int0 or /int1 interrupt is used, the respective flag should be cleared before enabling the interrupts to prevent an accidental inter- rupt. the pending flags are for the /int0 and /int1 interrupt are in the tcon register. 6.3.3.interrupt priorities each interrupt source can be individually programmed to one of two priority levels: low or high. a low prior- ity interrupt service routine can be preempted by a high priority interrupt. a high priority interrupt cannot be preempted. each interrupt has an associated interrupt priority bit in an sfr (ip or eip2) used to configure its priority level. low priority is the default. if two interrupts are recognized simultaneously, the interrupt with the higher priority is serviced first. if both interrupts have the same priority level, a fixed priority order is used to arbitrate, given in table6.4. 6.3.4.interrupt latency interrupt response time depends on the state of the cpu when the interrupt occurs. pending interrupts are sampled and priority decoded each system clock cycle. therefore, the fastest possible response time is 5 system clock cycles: 1clock cycle to detect the interrupt and 4clock cycles to complete the lcall to the isr. if an interrupt is pending when a reti is executed, a single instruction is executed before an lcall is made to service the pending interrupt. therefore, the maximum response time for an interrupt (when no other interrupt is currently being serviced or the new interrupt is of greater priority) occurs when the cpu is performing an reti instruction followed by a div as the next instruction. in this case, the response time is 18system clock cycles: 1clock cycle to detect the interrupt, 5clock cycles to execute the reti, 8clock cycles to complete the div instruction and 4clock cycles to execute the lcall to the isr. if the cpu is executing an isr for an interrupt with equal or higher priority, the new interrupt will not be serviced until the current isr completes, including the reti and following instruction. the cpu is stalled during flash write/erase operations. interrupt service latency will be increased for inter- rupts occurring while the cpu is stalled. the latency for these situations will be determined by the standard interrupt service procedure (as described above) and the amount of time the cpu is stalled.
C8051F326/7 52rev. 0.5 6.3.5.interrupt register descriptions the sfrs used to enable the interrupt sources and set their priority level are described below. refer to the data sheet section associated with a particular on-chip peripheral for information regarding valid interrupt conditions for the peripheral and the behavior of its interrupt-pending flag(s). table6.4.interrupt summary interrupt source interrupt vector priority order pending flag b i t a d d r e s s a b l e ? c l e a r e d b y h w ? enable flag priority control reset 0x0000 top none n/an/a always enabled always highest external interrupt 0 (/int0) 0x0003 0 ie0 (tcon.1) y yex0 (ie.0) px0 (ip.0) timer 0 overflow 0x000b 1 tf0 (tcon.5) y yet0 (ie.1)pt0 (ip.1) external interrupt 1 (/int1) 0x0013 2 ie1 (tcon.3) y yex1 (ie.2) px1 (ip.2) timer 1 overflow 0x001b 3 tf1 (tcon.7) y yet1 (ie.3)pt1 (ip.3) uart0 0x0023 4 ri0 (scon0.0) ti0 (scon0.1) y nes0 (ie.4) ps0 (ip.4) usb0 0x0043 8 special* n n eusb0 (eie1.1) pusb0 (eip1.1) vbus level 0x007b 15 n/a n/an/a evbus (eie2.0) pvbus (eip2.0) *note: see section 12.8 for more details about the usb interrupt.
rev. 0.553 C8051F326/7 sfr definition6.7.ie: interrupt enable bit7:ea: enable all interrupts. this bit globally enables/disables all interrupts. it overrides the individual interrupt mask set- tings. 0: disable all interrupt sources. 1: enable each interrupt according to its individual mask setting. bit6 C 5:unused. read = 00b. write = don t care. bit4:es0: enable uart0 interrupt. this bit sets the masking of the uart0 interrupt. 0: disable uart0 interrupt. 1: enable uart0 interrupt. bit3:et1: enable timer 1 interrupt. this bit sets the masking of the timer 1 interrupt. 0: disable all timer 1 interrupt. 1: enable interrupt requests generated by the tf1 flag. bit2:ex1: enable external interrupt 1. this bit sets the masking of external interrupt 1. 0: disable external interrupt 1. 1: enable interrupt requests generated by the /int1 input. bit1:et0: enable timer 0 interrupt. this bit sets the masking of the timer 0 interrupt. 0: disable all timer 0 interrupt. 1: enable interrupt requests generated by the tf0 flag. bit0:ex0: enable external interrupt 0. this bit sets the masking of external interrupt 0. 0: disable external interrupt 0. 1: enable interrupt requests generated by the /int0 input. r/wrrr/wr/wr/wr/wr/wreset value ea es0et1ex1et0ex000000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: (bit addressable) 0xa8
C8051F326/7 54rev. 0.5 sfr definition6.8.ip: interrupt priority bit7 C 5:unused. read = 100b, write = don't care. bit4:ps0: uart0 interrupt priority control. this bit sets the priority of the uart0 interrupt. 0: uart0 interrupt set to low priority level. 1: uart0 interrupts set to high priority level. bit3:pt1: timer 1 interrupt priority control. this bit sets the priority of the timer 1 interrupt. 0: timer 1 interrupt set to low priority level. 1: timer 1 interrupts set to high priority level. bit2:px1: external interrupt 1 priority control. this bit sets the priority of the external interrupt 1 interrupt. 0: external interrupt 1 set to low priority level. 1: external interrupt 1 set to high priority level. bit1:pt0: timer 0 interrupt priority control. this bit sets the priority of the timer 0 interrupt. 0: timer 0 interrupt set to low priority level. 1: timer 0 interrupt set to high priority level. bit0:px0: external interrupt 0 priority control. this bit sets the priority of the external interrupt 0 interrupt. 0: external interrupt 0 set to low priority level. 1: external interrupt 0 set to high priority level. rrrr/wr/wr/wr/wr/wreset value ps0pt1px1pt0px010000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: (bit addressable) 0xb8
rev. 0.555 C8051F326/7 sfr definition6.9.eie1: extended interrupt enable 1 sfr definition6.10.eip1: extended interrupt priority 1 sfr definition6.11.eie2: extended interrupt enable 2 bit7 C 2:unused. read = 000000b. write = don t care. bit1:eusb0: enable usb0 interrupt. this bit sets the masking of the usb0 interrupt. 0: disable all usb0 interrupts. 1: enable interrupt requests generated by usb0. bit0:unused. read = 0. write = don t care. rrrrrrr/wrreset value eusb0 00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0xe6 bit7 C 2:unused. read = 000000b. write = don t care. bit1:pusb0: usb0 interrupt priority control. this bit sets the priority of the usb0 interrupt. 0: usb0 interrupt set to low priority level. 1: usb0 interrupt set to high priority level. bit0:unused. read = 0. write = don t care. rrrrrrr/wrreset value pusb0 00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0xf6 bits7 C 1:unused. read = 0000000b. write = don t care. bit0:evbus: enable vbus level interrupt. this bit sets the masking of the vbus interrupt. 0: disable all vbus interrupts. 1: enable interrupt requests generated by vbus level sense. rrrrrrrr/wreset value evbus00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0xe7
C8051F326/7 56rev. 0.5 sfr definition6.12.eip2: extended interrupt priority 2 bits7 C 1:unused. read = 0000000b. write = don t care. bit0:pvbus: vbus level interrupt priority control. this bit sets the priority of the vbus interrupt. 0: vbus interrupt set to low priority level. 1: vbus interrupt set to high priority level. rrrrrrrr/wreset value pvbus00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0xf7
rev. 0.557 C8051F326/7 6.4.power management modes the cip-51 core has two software programmable power management modes: idle and stop. idle mode halts the cpu while leaving the peripherals and clocks active. in stop mode, the cpu is halted, all inter- rupts, are inactive, and the internal oscillator is stopped (the voltage regulator, low frequency oscillator, and external clock remain in their selected state). since clocks are running in idle mode, power consumption is dependent upon the system clock frequency and the number of peripherals left in active mode before entering idle. stop mode consumes the least power. figure6.13 describes the power control register (pcon) used to control the cip-51's power management modes. although the cip-51 has idle and stop modes built in (as with any standard 8051 architecture), power management of the entire mcu is better accomplished through system clock and individual peripheral management. digital peripherals, such as timers or uart, draw little power when they are not in use. turn- ing off the oscillators lowers power consumption considerably; however a reset is required to restart the mcu. the internal oscillator can be placed in suspend mode (see section 10.oscillators on page73 ). in suspend mode, the internal oscillator is stopped until a non-idle usb event is detected, or the vbus input signal matches the polarity selected by the vbpol bit in register reg0cn (figure5.1 on page36). 6.4.1.idle mode setting the idle mode select bit (pcon.0) causes the cip-51 to halt the cpu and enter idle mode as soon as the instruction that sets the bit completes execution. all internal registers and memory maintain their original data. all analog and digital peripherals can remain active during idle mode. idle mode is terminated when an enabled interrupt is asserted or a reset occurs. the assertion of an enabled interrupt will cause the idle mode selection bit (pcon.0) to be cleared and the cpu to resume operation. the pending interrupt will be serviced and the next instruction to be executed after the return from interrupt (reti) will be the instruction immediately following the one that set the idle mode select bit. if idle mode is terminated by an internal or external reset, the cip-51 performs a normal reset sequence and begins program execution at address 0x0000. 6.4.2.stop mode setting the stop mode select bit (pcon.1) causes the cip-51 to enter stop mode as soon as the instruc- tion that sets the bit completes execution. in stop mode the internal oscillator, cpu, and all digital peripher- als are stopped; the state of the low frequency oscillator is not affected. each analog peripheral (including the low frequency oscillator) may be shut down individually prior to entering stop mode. stop mode can only be terminated by an internal or external reset. on reset, the cip-51 performs the normal reset sequence and begins program execution at address 0x0000. if enabled, the missing clock detector will cause an internal reset and thereby terminate the stop mode. the missing clock detector should be disabled if the cpu is to be put to in stop mode for longer than the mcd timeout of 100 s.
C8051F326/7 58rev. 0.5 sfr definition6.13.pcon: power control bits7 C 2:gf5-gf0: general purpose flags 5-0. these are general purpose flags for use under software control. bit1:stop: stop mode select. setting this bit will place the cip-51 in stop mode. this bit will always be read as 0. 1: cpu goes into stop mode (internal oscillator stopped). bit0:idle: idle mode select. setting this bit will place the cip-51 in idle mode. this bit will always be read as 0. 1: cpu goes into idle mode. (shuts off clock to cpu, but clock to timers, interrupts, serial ports, and usb0 are still active.) r/wr/wr/wr/wr/wr/wr/wr/wreset value gf5gf4gf3gf2gf1gf0stopidle00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0x87
rev. 0.559 C8051F326/7 7.reset sources reset circuitry allows the controller to be easily placed in a predefined default condition. on entry to this reset state, the following occur: ? cip-51 halts program execution ? special function registers (sfrs) are initialized to their defined reset values ? external port pins are forced to a known state ? interrupts and timers are disabled. all sfrs are reset to the predefined values noted in the sfr detailed descriptions. the contents of internal data memory are unaffected during a reset; any previously stored data is preserved. however, since the stack pointer sfr is reset, the stack is effectively lost even though the data on the stack is not altered. the port i/o latches are reset to 0xff (all logic ones) in open-drain mode. weak pullups are enabled dur- ing and after the reset. for vdd monitor and power-on resets, the rst pin is driven low until the device exits the reset state. on exit from the reset state, the program counter (pc) is reset, and the system clock defaults to the inter- nal oscillator. refer to section 10.oscillators on page73 for information on selecting and configuring the system clock source. program execution begins at location 0x0000. figure 7.1. reset sources missing clock detector (one- shot) (software reset) system reset reset funnel en swrsf internal oscillator system clock cip-51 microcontroller core extended interrupt handler clock select m c d e n a b l e xtal2 external clock input errant flash operation /rst (wired-or) power on reset + - vdd supply monitor enable '0' low frequency oscillator
C8051F326/7 60rev. 0.5 7.1.power-on reset during power-up, the device is held in a reset state and the rst pin is driven low until vdd settles above v rst . a power-on reset delay (t pordelay ) occurs before the device is released from reset; this delay is typically less than 0.3ms.figure7.2. plots the power-on and vdd monitor reset timing. on exit from a power-on reset, the porsf flag (rstsrc.1) is set by hardware to logic 1. when porsf is set, all of the other reset flags in the rstsrc register are indeterminate (porsf is cleared by all other resets). since all resets cause program execution to begin at the same location (0x0000) software can read the porsf flag to determine if a power-up was the cause of reset. the content of internal data mem- ory should be assumed to be undefined after a power-on reset. the vdd monitor is enabled following a power-on reset. software can force a power-on reset by writing 1 to the pinrsf bit in register rstsrc. figure 7.2. power-on and vdd monitor reset timing power-on reset vdd monitor reset /rst t v o l t s 1.0 2.0 logic high logic low t pordelay v d d 2.70 2.4 v rst vdd
rev. 0.561 C8051F326/7 7.2.power-fail reset / vdd monitor when a power-down transition or power irregularity causes vdd to drop below v rst , the power supply monitor will drive the rst pin low and hold the cip-51 in a reset state (see figure7.2). when vdd returns to a level above v rst , the cip-51 will be released from the reset state. note that even though internal data memory contents are not altered by the power-fail reset, it is impossible to determine if vdd dropped below the level required for data retention. if the porsf flag reads 1 , the data may no longer be valid. the vdd monitor is enabled after power-on resets; however its defined state (enabled/disabled) is not altered by any other reset source. for example, if the vdd monitor is enabled and a software reset is per- formed, the vdd monitor will still be enabled after the reset. important note: the vdd monitor must be enabled before it is selected as a reset source. selecting the vdd monitor as a reset source before it is enabled and stabilized will cause a system reset.the procedure for configuring the vdd monitor as a reset source is shown below: step 1. enable the vdd monitor (vdm0cn.7 = 1 ). step 2. wait for the vdd monitor to stabilize (see table 7.1 for the vdd monitor turn-on time). step 3. select the vdd monitor as a reset source (rstsrc.1 = 1 ). see figure7.2 for vdd monitor timing. see table7.1 for complete electrical characteristics of the vdd monitor. sfr definition7.1.vdm0cn: vdd monitor control bit7:vdmen: vdd monitor enable. this bit turns the vdd monitor circuit on/off. the vdd monitor cannot generate system resets until it is also selected as a reset source in register rstsrc (figure 7.2). the vdd monitor must be allowed to stabilize before it is selected as a reset source. selecting the vdd monitor as a reset source before it has stabilized may generate a system reset. see table 7.1 for the minimum vdd monitor turn-on time. the vdd monitor is enabled fol- lowing all por resets. 0: vdd monitor disabled. 1: vdd monitor enabled. bit6: vddstat: vdd status. this bit indicates the current power supply status (vdd monitor output). 0: vdd is at or below the vdd monitor threshold. 1: vdd is above the vdd monitor threshold. bits5 C 0: reserved. read = variable. write = don t care. r/wrrrrrrrreset value vdmenvddstatreservedreservedreservedreservedreservedreservedvariable bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0xff
C8051F326/7 62rev. 0.5 7.3.external reset the external rst pin provides a means for external circuitry to force the device into a reset state. assert- ing an active-low signal on the rst pin generates a reset; an external pullup and/or decoupling of the rst pin may be necessary to avoid erroneous noise-induced resets. see table7.1 for complete rst pin spec- ifications. the pinrsf flag (rstsrc.0) is set on exit from an external reset. 7.4.missing clock detector reset the missing clock detector (mcd) is a one-shot circuit that is triggered by the system clock. if more than 100 s pass between rising edges on the system clock, the one-shot will time out and generate a reset. after a mcd reset, the mcdrsf flag (rstsrc.2) will read 1 , signifying the mcd as the reset source; otherwise, this bit reads 0 . writing a 1 to the mcdrsf bit enables the missing clock detector; writing a 0 disables it. the state of the rst pin is unaffected by this reset. 7.5.flash error reset if a flash read/write/erase or program read targets an illegal address, a system reset is generated. this may occur due to any of the following: ? a flash write or erase is attempted above user code space. this occurs when pswe is set to 1 and a movx write operation is attempted above address 0x3dff. ? a flash read is attempted above user code space. this occurs when a movc operation is attempted above address 0x3dff. ? a program read is attempted above user code space. this occurs when user code attempts to branch to an address above 0x3dff. ? a flash read, write or erase attempt is restricted due to a flash security setting (see section 8.3.security options on page67 ). the ferror bit (rstsrc.6) is set following a flash error reset. the state of the rst pin is unaffected by this reset. 7.6.software reset software may force a reset by writing a 1 to the swrsf bit (rstsrc.4). the swrsf bit will read 1 fol- lowing a software forced reset. the state of the rst pin is unaffected by this reset. 7.7.usb reset writing 1 to the usbrsf bit in register rstsrc selects usb0 as a reset source. with usb0 selected as a reset source, a system reset will be generated when either of the following occur: 1.reset signaling is detected on the usb network. the usb function controller (usb0) must be enabled for reset signaling to be detected. see section 12.universal serial bus con- troller (usb0) on page89 for information on the usb function controller. 2.the voltage on the vbus pin matches the polarity selected by the vbpol bit in register reg0cn. see section 5.voltage regulator (reg0) on page33 for details on the vbus detection circuit. the usbrsf bit will read 1 following a usb reset. the state of the rst pin is unaffected by this reset.
rev. 0.563 C8051F326/7 sfr definition7.2.rstsrc: reset source bit7:usbrsf: usb reset flag 0: read: last reset was not a usb reset; write: usb resets disabled. 1: read: last reset was a usb reset; write: usb resets enabled. bit6:ferror: flash error indicator. 0: source of last reset was not a flash read/write/erase error. 1: source of last reset was a flash read/write/erase error. bit5:unused. read = 0. write = don t care. bit4:swrsf: software reset force and flag. 0: read: source of last reset was not a write to the swrsf bit; write: no effect. 1: read: source of last was a write to the swrsf bit; write: forces a system reset. bit3:unused. read = 0. write = don t care. bit2:mcdrsf: missing clock detector flag. 0: read: source of last reset was not a missing clock detector timeout; write: missing clock detector disabled. 1: read: source of last reset was a missing clock detector timeout; write: missing clock detector enabled; triggers a reset if a missing clock condition is detected. bit1:porsf: power-on / vdd monitor reset flag. this bit is set anytime a power-on reset occurs. writing this bit selects/deselects the vdd monitor as a reset source. note: writing 1 to this bit before the vdd monitor is enabled and stabilized can cause a system reset. see register vdm0cn (figure 7.1). 0: read: last reset was not a power-on or vdd monitor reset; write: vdd monitor is not a reset source. 1: read: last reset was a power-on or vdd monitor reset; all other reset flags indetermi- nate; write: vdd monitor is a reset source. bit0:pinrsf: hw pin reset flag. 0: source of last reset was not rst pin. 1: source of last reset was rst pin. note: do not use read-modify-write instructions on this register. r/wrrr/wrr/wr/wrreset value usbrsfferror swrsf mcdrsfporsfpinrsfvariable bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0xef
C8051F326/7 64rev. 0.5 table7.1.reset electrical characteristics C 40 to +85 c unless otherwise specified. parameterconditionsmintypmaxunits f326 rst output voltage i ol = 8.5 ma; vio = 2.7 to 3.6v i ol = tbd; vio = 2.0v; 0.6 tbd v f327 rst output voltage i ol = tbd; vio = 2.7 to 3.6v tbd v rst input high voltage* 0.7 x vio v rst input low voltage* 0.3 x vio v f326 rst pullup current 10 26 40 a f327 rst pullup current 26 40 a vdd monitor threshold (v rst ) 2.40 2.55 2.70 v missing clock detector timeouttime from last system clock rising edge to reset initiation 100 240 500 s reset time delay delay between the release of any reset source and code execution at location 0x0000 5.0 s minimum rst low time to generate a system reset 15 s vdd monitor turn-on time 100 s vdd monitor supply current 45 tbd a *note: on 'f327 devices, vio = vdd.
rev. 0.565 C8051F326/7 8.flash memory on-chip, re-programmable flash memory is included for program code and non-volatile data storage. the flash memory can be programmed in-system, a single byte at a time, through the c2 interface or by soft- ware using the movx instruction. once cleared to logic 0, a flash bit must be erased to set it back to logic 1. flash bytes would typically be erased (set to 0xff) before being reprogrammed. the write and erase operations are automatically timed by hardware for proper execution; data polling to determine the end of the write/erase operation is not required. code execution is stalled during a flash write/erase operation. refer to table8.1 for complete flash memory electrical characteristics. 8.1.programming the flash memory the simplest means of programming the flash memory is through the c2 interface using programming tools provided by silicon laboratories or a third party vendor. this is the only means for programming a non-initialized device. for details on the c2 commands to program flash memory, see section 15.c2 interface on page137 . to ensure the integrity of flash contents, it is strongly recommended that the on-chip vdd monitor be enabled in any system that includes code that writes and/or erases flash memory from soft- ware. 8.1.1.flash lock and key functions flash writes and erases by user software are protected with a lock and key function. the flash lock and key register (flkey) must be written with the correct key codes, in sequence, before flash operations may be performed. the key codes are: 0xa5, 0xf1. the timing does not matter, but the codes must be written in order. if the key codes are written out of order, or the wrong codes are written, flash writes and erases will be disabled until the next system reset. flash writes and erases will also be disabled if a flash write or erase is attempted before the key codes have been written properly. the flash lock resets after each write or erase; the key codes must be written again before a following flash operation can be per- formed. the flkey register is detailed in figure8.2. 8.1.2.flash erase procedure the flash memory can be programmed by software using the movx write instruction with the address and data byte to be programmed provided as normal operands. before writing to flash memory using movx, flash write operations must be enabled by: (1) writing the flash key codes in sequence to the flash lock register (flkey); and (2) setting the pswe program store write enable bit (psctl.0) to logic 1 (this directs the movx writes to target flash memory). the pswe bit remains set until cleared by software. a write to flash memory can clear bits to logic 0 but cannot set them; only an erase operation can set bits to logic 1 in flash. a byte location to be programmed must be erased before a new value is written. the flash memory is organized in 512-byte pages. the erase operation applies to an entire page (setting all bytes in the page to 0xff). to erase an entire 512-byte page, perform the following steps: step 1. disable interrupts (recommended). step 2. write the first key code to flkey: 0xa5. step 3. write the second key code to flkey: 0xf1. step 4. set the psee bit (register psctl). step 5. set the pswe bit (register psctl). step 6. using the movx instruction, write a data byte to any location within the 512-byte page to be erased. step 7. clear the pswe bit (register psctl). step 8. clear the psee bit (register pscti).
C8051F326/7 66rev. 0.5 8.1.3.flash write procedure flash bytes are programmed by software with the following sequence: step 1. disable interrupts (recommended). step 2. erase the 512-byte flash page containing the target location, as described in section 8.1.2 . step 3. write the first key code to flkey: 0xa5. step 4. write the second key code to flkey: 0xf1. step 5. set the pswe bit (register psctl). step 6. clear the psee bit (register psctl). step 7. using the movx instruction, write a single data byte to the desired location within the 512- byte sector. step 8. clear the pswe bit (register psctl). steps 3-8 must be repeated for each byte to be written. after flash writes are complete, pswe should be cleared so that movx instructions do not target program memory. table8.1.flash electrical characteristics parameterconditionsmintypmaxunits flash sizeC8051F326/7 16384* bytes endurance20k100k erase/write erase cycle time25 mhz system clock101520ms write cycle time25 mhz system clock405570 s *note: 512 bytes at location 0x3e00 to 0x3fff are reserved.
rev. 0.567 C8051F326/7 8.2.non-volatile data storage the flash memory can be used for non-volatile data storage as well as program code. this allows data such as calibration coefficients to be calculated and stored at run time. data is written using the movx write instruction and read using the movc instruction. note: movx read instructions always target xram. 8.3.security options the cip-51 provides security options to protect the flash memory from inadvertent modification by soft- ware as well as to prevent the viewing of proprietary program code and constants. the program store write enable (bit pswe in register psctl) and the program store erase enable (bit psee in register psctl) bits protect the flash memory from accidental modification by software. pswe must be explicitly set to 1 before software can modify the flash memory; both pswe and psee must be set to 1 before software can erase flash memory. additional security features prevent proprietary program code and data constants from being read or altered across the c2 interface. a security lock byte located at the last byte of flash user space offers protection of the flash program memory from access (reads, writes, or erases) by unprotected code or the c2 interface. the flash security mechanism allows the user to lock n 512-byte flash pages, starting at page 0 (addresses 0x0000 to 0x01ff), where n is the 1 s compliment number represented by the security lock byte. see example below. important notes about the flash security: 1.clearing any bit of the lock byte to 0 will lock the flash page containing the lock byte (in addition to the selected pages). 2.locked pages cannot be read, written, or erased via the c2 interface. 3.locked pages cannot be read, written, or erased by user firmware executing from unlocked memory space. 4.user firmware executing in a locked page may read and write flash memory in any locked or unlocked page excluding the reserved area. 5.user firmware executing in a locked page may erase flash memory in any locked or unlocked page excluding the reserved area and the page containing the lock byte. 6.locked pages can only be unlocked through the c2 interface with a c2 device erase com- mand. 7.if a user firmware flash access attempt is denied (per restrictions #3, #4, and #5 above), a flash error system reset will be generated. security lock byte:11111101b 1s compliment:00000010b flash pages locked:2 addresses locked:0x0000 to 0x03ff
C8051F326/7 68rev. 0.5 figure 8.1. flash program memory map and security byte sfr definition8.1.psctl: program store r/w control access limit set according to the flash security lock byte C8051F326/7 0x0000 0x3dff lock byte reserved 0x3dfe 0x3e00 flash memory organized in 512-byte pages 0x3c00 unlocked flash pages locked when any other flash pages are locked bits7 C 3:unused: read = 00000b. write = don t care. bit2:reserved. read = 0b. must write = 0b. bit1:psee: program store erase enable setting this bit (in combination with pswe) allows an entire page of flash program memory to be erased. if this bit is logic 1 and flash writes are enabled (pswe is logic 1), a write to flash memory using the movx instruction will erase the entire page that contains the loca- tion addressed by the movx instruction. the value of the data byte written does not matter. 0: flash program memory erasure disabled. 1: flash program memory erasure enabled. bit0:pswe: program store write enable setting this bit allows writing a byte of data to the flash program memory using the movx write instruction. the flash location should be erased before writing data. 0: writes to flash program memory disabled. 1: writes to flash program memory enabled; the movx write instruction targets flash memory. r/wr/wr/wr/wr/wr/wr/wr/wreset value reservedpseepswe00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0x8f
rev. 0.569 C8051F326/7 sfr definition8.2.flkey: flash lock and key sfr definition8.3.flscl: flash scale bits7 C 0:flkey: flash lock and key register write: this register must be written to before flash writes or erases can be performed. flash remains locked until this register is written to with the following key codes: 0xa5, 0xf1. the timing of the writes does not matter, as long as the codes are written in order. the key codes must be written for each flash write or erase operation. flash will be locked until the next system reset if the wrong codes are written or if a flash operation is attempted before the codes have been written correctly. read: when read, bits 1-0 indicate the current flash lock state. 00: flash is write/erase locked. 01: the first key code has been written (0xa5). 10: flash is unlocked (writes/erases allowed). 11: flash writes/erases disabled until the next reset. r/wr/wr/wr/wr/wr/wr/wr/wreset value 00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0xb7 bits7:fose: flash one-shot enable this bit enables the flash read one-shot. when the flash one-shot disabled, the flash sense amps are enabled for a full clock cycle during flash reads. at system clock frequen- cies below 10 mhz, disabling the flash one-shot will increase system power consumption. 0: flash one-shot disabled. 1: flash one-shot enabled. bits6 C 0:reserved. read = 0. must write 0. r/wr/wr/wr/wr/wr/wr/wr/wreset value fosereservedreservedreservedreservedreservedreservedreserved10000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0xb6
C8051F326/7 70rev. 0.5 n otes :
rev. 0.571 C8051F326/7 9.external ram the C8051F326/7 devices include 1280bytes of on-chip xram. this xram space is split into user ram (addresses 0x0000 C 0x03ff) and usb0 fifo space. the usb0 fifo space is only accessible through the usb fifo registers. figure 9.1. external ram memory map 9.1.accessing user xram user xram can be accessed using the external move instruction (movx) and the data pointer (dptr), or using movx indirect addressing mode. if the movx instruction is used with an 8-bit address operand (such as @r1), then the high byte of the 16-bit address is provided by the external memory interface con- trol register (emi0cn as shown in figure9.1). note: the movx instruction is also used for writes to the flash memory. see section 8.flash memory on page65 for details. the movx instruction accesses xram by default. for any of the addressing modes, the upper 6 bits of the 16-bit external data memory address word are "don't cares". as a result, the 1024-byte ram is mapped modulo style over the entire 64k external data memory address range. for example, the xram byte at address 0x0000 is also at address 0x0400, 0x0800, 0x0c00, 0x1000, etc. xram 1024 bytes 0x0000 0x03ff same 1024 bytes as from 0x0000 to 0x03ff, wrapped on 1k-byte boundaries 0x0400 0xffff usb fifos 256 bytes accessed only through usb fifo registers (inaccessible using the movx instruction) accessed with the movx instruction
C8051F326/7 72rev. 0.5 9.2.accessing usb fifo space the upper 256 bytes of xram functions as usb fifo space. figure9.2 shows an expanded view of the fifo space and user xram. fifo space is accessed via usb fifo registers; see section 12.5.fifo management on page97 for more information on accessing these fifos. the fifo block operates on the usb clock domain; thus the usb clock must be active when accessing fifo space. important note: the usb clock must be active when accessing fifo space. figure 9.2. xram memory map expanded view sfr definition9.1.emi0cn: external memory interface control endpoint0 (64 bytes) 0x00 0xbf 0xc0 0xff user xram (1024 bytes) 0x0000 0x03ff endpoint1 usb fifo space (usb clock domain) user xram space (system clock domain) in (64 bytes) out (128 bytes) bits7 C 3: unused. read = 000000b. write = don t care. bits2 C 0:pgsel[1:0]: xram page select bits. the xram page select bits provide the high byte of the 16-bit external data memory address when using an 8-bit movx command, effectively selecting a 256-byte page of ram. the upper 6-bits are "don't cares", so the 1k address block is repeated modulo over the entire 64k external data memory address space. r/wr/wr/wr/wr/wr/wr/wr/wreset value ------pgsel1pgsel000000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0xaa
rev. 0.573 C8051F326/7 10.oscillators C8051F326/7 devices include a programmable internal oscillator, an external clock input circuit, a low fre- quency internal oscillator, and a 4x clock multiplier. the internal oscillator can be enabled/disabled and calibrated using the oscicn and oscicl registers, as shown in figure10.1. the low frequency oscilla- tor can be enabled/disabled and calibrated using the osclcn register, as shown in figure10.3. the sys- tem clock (sysclk) can be derived from the internal oscillator, external clock, low frequency oscillator, or the 4x clock multiplier divided by 2. the usb clock (usbclk) can be derived from the internal oscillator divided by 2, external clock, or 4x clock multiplier. oscillator electrical specifications are given in table10.3 on page80. figure 10.1. oscillator diagram 10.1.programmable internal oscillator all C8051F326/7 devices include a programmable internal oscillator that defaults as the system clock after a system reset. the internal oscillator period can be adjusted via the oscicl register. on C8051F326/7 devices, oscicl is factory calibrated to obtain a 12mhz frequency. electrical specifications for the preci- sion internal oscillator are given in table10.3 on page80. note that the system clock may be derived from the programmed internal oscillator divided by 1, 2, 4, or 8, as defined by the ifcn bits in register oscicn. the divide value defaults to 8 following a reset. clock multiplier exosc input circuit xtal2 clkmul m u l e n m u l i n i t m u l r d y m u l s e l 1 m u l s e l 0 programmable internal clock generator en oscicl oscicn i o s c e n i f r d y s u s p e n d i f c n 1 i f c n 0 iosc n x 2 x 2 exosc iosc sysclk exosc iosc / 2 usbclk u s b c l k 1 - 0 clksel u s b c l k 1 u s b c l k 0 c l k s e l 2 c l k s l 1 c l k s l 0 cmos clock osclcn o s c l e n low frequency oscillator osclf en off (0 hz)
C8051F326/7 74rev. 0.5 10.1.1.adjusting the internal oscillator on C8051F326/7 devices the oscicl reset value is factory calibrated to result in a 12mhz internal oscillator with a 1.5% accu- racy; this frequency is suitable for use as the usb clock (see section 10.4 ). software may adjust the fre- quency of the internal oscillator using the oscicl register. important note: once the internal oscillator frequency has been modified, the internal oscillator may not be used as the usb clock as described in section 10.4 . the internal oscillator frequency will reset to its original factory-calibrated frequency following any device reset, at which point the oscillator is suitable for use as the usb clock. 10.1.2.internal oscillator suspend mode the internal oscillator may be placed in suspend mode by writing 1 to the suspend bit in register oscicn. in suspend mode, the internal oscillator is stopped until a non-idle usb event is detected ( sec- tion 12 ) or vbus matches the polarity selected by the vbpol bit in register reg0cn ( section 5.2 ). note that the usb transceiver must be enabled or in suspend mode for a usb event to be detected. sfr definition10.1.oscicn: internal oscillator control bit7:ioscen: internal oscillator enable bit. 0: internal oscillator disabled. 1: internal oscillator enabled. bit6:ifrdy: internal oscillator frequency ready flag. 0: internal oscillator is not running at programmed frequency. 1: internal oscillator is running at programmed frequency. bit5:suspend: force suspend writing a 1 to this bit will force the internal oscillator to be stopped. the oscillator will be re- started on the next non-idle usb event (i.e., resume signaling) or vbus interrupt event (see sfr definition 5.1). bits4 C 2: unused. read = 000b, write = don't care. bits1 C 0:ifcn1 C 0: internal oscillator frequency control bits. 00: sysclk derived from internal oscillator divided by 8. 01: sysclk derived from internal oscillator divided by 4. 10: sysclk derived from internal oscillator divided by 2. 11: sysclk derived from internal oscillator divided by 1. r/wrr/wrr/wr/wr/wr/wreset value ioscenifrdysuspend ifcn1ifcn011000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0xb2
rev. 0.575 C8051F326/7 sfr definition10.2.oscicl: internal oscillator calibration bits4 C 0:osccal: oscillator calibration value these bits determine the internal oscillator period. note: if the sum of the reset value of osccal and osccal is greater than 31 or less than 0, then the device will not be capable of producing the desired frequency. note: the contents of this register are undefined when clock recovery is enabled. see section 12.4. usb clock configuration on page 96 for details on clock recovery. r/wr/wr/wr/wr/wr/wr/wr/wreset value osccalvariable bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0xb3
C8051F326/7 76rev. 0.5 10.2.internal low-frequency (l-f) oscillator C8051F326/7 devices include a low-frequency oscillator. the osclcn register (see sfr definition 10.3) is used to enabled the oscillator. sfr definition10.3.osclcn: internal l-f oscillator control bit7:osclen: internal l-f oscillator enable. 0: internal l-f oscillator disabled. 1: internal l-f oscillator enabled. bit6 C 0:unused. read = 0000000b; write = don t care. r/wrrrrrrrreset value osclen 0xxxxxxx bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0xe3
rev. 0.577 C8051F326/7 10.3.4x clock multiplier the 4x clock multiplier allows a 12mhz oscillator to generate the 48mhz clock required for full speed usb communication (see section 12.4.usb clock configuration on page96 ). a divided version of the multiplier output can also be used as the system clock. see section 10.4 for details on system clock and usb clock source selection. the 4x clock multiplier is configured via the clkmul register. the procedure for configuring and enabling the 4x clock multiplier is as follows: 1.reset the multiplier by writing 0x00 to register clkmul. 2.select the multiplier input source via the mulsel bits. 3.enable the multiplier with the mulen bit (clkmul | = 0x80). 4.delay for >5 s. 5.initialize the multiplier with the mulinit bit (clkmul | = 0xc0). 6.poll for mulrdy => 1 . important note: when using an external clock as the input to the 4x clock multiplier, the external source must be stable before the multiplier is initialized. see section 10.4 for details on clock selec- tion. sfr definition10.4.clkmul: clock multiplier control bit7:mulen: clock multiplier enable 0: clock multiplier disabled. 1: clock multiplier enabled. bit6:mulinit: clock multiplier initialize this bit should be a 0 when the clock multiplier is enabled. once enabled, writing a 1 to this bit will initialize the clock multiplier. the mulrdy bit reads 1 when the clock multiplier is stabilized. bit5:mulrdy: clock multiplier ready this read-only bit indicates the status of the clock multiplier. 0: clock multiplier not ready. 1: clock multiplier ready (locked). bits4 C 1:unused. read = 0000b; write = don t care. bit0:mulsel: clock multiplier input select these bits select the clock supplied to the clock multiplier. r/wr/wrr/wr/wr/wr/wr/wreset value mulenmulinitmulrdy mulsel00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address 0xb9 mulselselected clock 0internal oscillator 1external clock
C8051F326/7 78rev. 0.5 10.4.system and usb clock selection the internal oscillator requires little start-up time and may be selected as the system or usb clock immedi- ately following the oscicn write that enables the internal oscillator. if the external clock is selected as the system or usb clock, then startup times may vary based on the specifications of the external clock. 10.4.1.system clock selection the clksl[2:0] bits in register clksel select which oscillator source is used as the system clock. clksl[2:0] must be set to 001b for the system clock to run from the external clock; however the external clock may still clock certain peripherals (timers, uart, usb) when the internal oscillator is selected as the system clock. the system clock may be switched on-the-fly between the internal oscillator, external clock, low frequency oscillator, and 4x clock multiplier so long as the selected oscillator is enabled and can pro- vide a stable clock. 10.4.2.usb clock selection the usbclk[1:0] bits in register clksel select which oscillator source is used as the usb clock. the usb clock may be derived from the 4x clock multiplier output, internal oscillator divided by 2, or an exter- nal clock. the usb clock source may also be turned off. the usb clock must be 48mhz when operating usb0 as a full speed function; the usb clock must be 6mhz when operating usb0 as a low speed function. see figure10.5 for usb clock selection options. some example usb clock configurations for full and low speed mode are given below: table10.1.typical usb full speed clock settings internal oscillator clock signalinput source selectionregister bit settings usb clockclock multiplierusbclk = 00b clock multiplier inputinternal oscillator*mulsel = 0b internal oscillatordivide by 1ifcn = 11b external clock clock signalinput source selectionregister bit settings usb clockclock multiplierusbclk = 10b clock multiplier inputexternal clockmulsel = 1b port i/o 12 mhz cmos clockinputen = 1b (gpi- ocn.6) *note: clock recovery must be enabled for this configuration. table10.2.typical usb low speed clock settings internal oscillator clock signalinput source selectionregister bit settings usb clockinternal oscillator / 2usbclk = 01b internal oscillatordivide by 1ifcn = 11b external clock clock signalinput source selectionregister bit settings usb clockexternal clockusbclk = 10b port i/o 6 mhz cmos clockinputen = 1b (gpi- ocn.6)
rev. 0.579 C8051F326/7 sfr definition10.5.clksel: clock select bits7 C 6:unused. read = 0b; write = don t care. bits5 C 4:usbclk1 C 0: usb clock select these bits select the clock supplied to usb0. when operating usb0 in full-speed mode, the selected clock should be 48 mhz. when operating usb0 in low-speed mode, the selected clock should be 6 mhz. bit3:unused. read = 0b; write = don t care. bits2 C 0:clksl1 C 0: system clock select these bits select the system clock source. r/wr/wr/wr/wr/wr/wr/wr/wreset value usbclk clksl00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address 0xa9 usbclkselected clock 004x clock multiplier 01internal oscillator / 2 10external oscillator 11clock off (0 hz) clkslselected clock 000 internal oscillator (as determined by the ifcn bits in register oscicn) 001external clock 0104x clock multiplier / 2 011low frequency oscillator 1xxreserved
C8051F326/7 80rev. 0.5 table10.3.internal oscillator electrical characteristics C 40 to +85 c unless otherwise specified. parameter conditions min typ max units internal high-frequency oscillator internal oscillator frequencyreset frequency 11.82 12 12.18 mhz internal oscillator supply current (from vdd) oscicn.7 = 1 574 a usb clock frequency 1 full speed mode low speed mode 47.88 5.91 48 6 48.12 6.09 mhz internal low-frequency oscillator (using factory-calibrated settings) internal oscillator frequency 88 khz internal oscillator supply current (from vdd) 25 o c, vdd = 3.0v, osclcn.7 = 1 17 a power supply sensitivity constant temperature C 3 0.1 2 %/v temperature sensitivity constant supply 20 8 ppm/ o c notes: 1. applies only to external oscillator sources. 2. represents mean 1 standard deviation.
rev. 0.581 C8051F326/7 11.port input/output on-chip digital resources are available through 15 i/o pins. port pins are organized as shown in figure11.1. each of the port pins can be used as general-purpose i/o (gpio). some port pins can be dedicated to special signals such as /sysclk, uart tx and rx, and xtal2 external clock input. all port i/os are 5v tolerant (refer to figure11.2 for the port cell circuit). the port i/o cells are configured as either push-pull or open-drain in the port output mode registers (pnmdout, where n = 0,2,3). com- plete electrical specifications for port i/o are given in table11.1 on page87. figure 11.1. port i/o functional block diagram i/o cell pnmdout and xbr1 registers: output mode -- push-pull or open-drain global input enable -- inputen global weak pull-up disable -- weakpud uart /sysclk p2.0 p2.5 p3.0 6 p3.0 i/o cells p0.0 p0.1 p0.3 i/o cell p0.5 i/o cell i/o cells p0.4 p0.6 p0.7 i/o cell i/o cells (p0.0 - in) mux p0.0 (p0.0 - out) gpiocn.0 p0.4 p0.5 (p0.4 - in) (p0.5 - in) (p0.4 - out) (p0.5 - out) p0.6 p0.7 2 3 p2.0 p2.5 p0.1 p0.3 1
C8051F326/7 82rev. 0.5 figure 11.2. port i/o cell block diagram gnd logic 0 port-output push-pull vdd vdd /weak-pullup (weak) port pad inputen port-input
rev. 0.583 C8051F326/7 11.1.port i/o initialization port i/o initialization consists of the following steps: step 1. select if the port pin will be used as an output or input. step 2. if output, select the output mode: open-drain or push-pull. step 3. configure the pnmdout and pn latches according to the desired input or output configuration. step 4. select if /sysclk will appear on the p0.0 output and configure gpiocn.0. step 5. enable global inputs (inputen = 1). port pins can be used as digital inputs or outputs. to configure a port pin as a digital input, write 0 to the corresponding bit in register pnmdout, and write 1 to the corresponding port latch (register pn). when a port pin is read, the actual voltage at the pin is used to determine a logic 0 or logic 1 value; the port latch is write-only. digital output pins can be configured to open-drain or push-pull. in open drain mode (corresponding bit in pnmdout is set to 0 ), the low output driver is turned on when the port latch is a logic 0 and turned off when the port latch is a logic 1. the high output driver is always off, regardless of the port latch setting. in open drain mode, an output port pin becomes a high impedance input when the port latch is a logic 1. an external pullup resistor is recommended if the pin is intended for use as an output. this mode is useful when interfacing to 5v logic. each port pin has an internal weak pullup that is enabled when the weakpud bit 0 , the port output mode is configured as open-drain, and the port latch is a logic 1 (pin is a high impedance input). the weak pullup is disabled if the pin is configured to push-pull mode or the port latch is a logic 0 to avoid unnecessary power dissipation. in push-pull mode (corresponding bit in pnmdout is set to 1 ), one of the output drivers will always remain on. when the port latch is a logic 0, the low output driver is turned on and the high output driver is off. when the port latch is a logic 1, the low output driver is turned off and the high output driver is turned on. note that in push-pull mode, the voltage at the port pin will reflect the logic level of the output port latch. this mode cannot be used to drive logic levels higher than vio or vdd. after each port pin is properly configured as an input or output, special signals can be routed to select port pins. special signals include /sysclk on p0.0, xtal2 clock input on p0.3, uart tx on p0.4, and uart rx on p0.5. the /sysclk signal can be routed to p0.0 by setting gpiocn.0 to 1 . the xtal2 clock input is always routed to p0.3. the uart tx signal is always enabled, and anded with the p0.4 latch. when using the uart, the p0.4 port latches should be logic 1 to allow the uart to control the tx pin. if the port latch is written 0 at any time, the tx signal will be forced to a logic 0. when the uart is not used, the value of the tx signal is parked at logic 1 and p0.4 can be used as gpio. important note: setting the inputen bit in gpiocn to 1 globally enables digital inputs. until global inputs are enabled, all port pins on the device remain as output only and cannot be used to sense the logic level on the port pin. inputen must be set to 1 in order to use uart rx, xtal2, or the /int0 input. 11.2.general purpose port i/o port0, port2, and port3 are accessed through corresponding special function registers (sfrs) that are both byte addressable and bit addressable. when writing to a port, the value written to the sfr is latched to maintain the output data value at each pin. when reading, the logic levels of the port's input pins are returned if inputen is set to 1 . the exception to this is the execution of the read-modify-write instruc- tions. the read-modify-write instructions when operating on a port sfr are the following: anl, orl, xrl, jbc, cpl, inc, dec, and djnz. the mov, clr and setb instructions are also read-modify-write when the destination is an individual bit in a port sfr. for these instructions, the value of the register (not the pin) is read, modified, and written back to the sfr.
C8051F326/7 84rev. 0.5 sfr definition11.1.gpiocn: global port i/o control sfr definition11.2.p0: port0 sfr definition11.3.p0mdout: port0 output mode bit7:weakpud: port i/o weak pullup disable. 0: weak pullups enabled (except for i/o pins with port latches set to logic 0 or are config- ured to push-pull mode). 1: weak pullups disabled. bit6:inputen: global digital input enable. 0: port i/o input path disabled; port pins can be used as outputs only. 1: port i/o input path enabled. bits5 C 1:unused. read = 00000b. write = don t care. bit0:sysclk: /sysclk enable 0: /sysclk unavailable at p0.0 pin. p0.0 latch routed to p0.0 pin. 1: /sysclk routed to p0.0. p0.0 latch unavailable at p0.0 pin. r/wr/wrrrrrr/wreset value weakpudinputen sysclk01000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0xe2 bits7 C 0:p0.[7:0] write - output appears on i/o pins. 0: logic low output. 1: logic high output (high impedance if corresponding p0mdout.n bit = 0). read - always reads 0 if inputen = 0 . otherwise, directly reads port pin. 0: p0.n pin is logic low. 1: p0.n pin is logic high. r/wr/wr/wr/wr/wr/wr/wr/wreset value p0.7p0.6p0.5p0.4p0.3p0.2p0.1p0.011111111 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: (bit addressable) 0x80 bits7 C 0:output configuration bits for p0.7-p0.0 (respectively): 0: corresponding p0.n output is open-drain. 1: corresponding p0.n output is push-pull. r/wr/wr/wr/wr/wr/wr/wr/wreset value 00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0xa4
rev. 0.585 C8051F326/7 sfr definition11.4.p2: port2 sfr definition11.5.p2mdout: port2 output mode sfr definition11.6.p3: port3 bits7 C 6:unused bits5 C 0:p2.[5:0] write - output appears on i/o pins. 0: logic low output. 1: logic high output (high impedance if corresponding p2mdout.n bit = 0). read - always reads 0 if inputen = 0 . otherwise, directly reads port pin. 0: p2.n pin is logic low. 1: p2.n pin is logic high. r/wr/wr/wr/wr/wr/wr/wr/wreset value p2.5p2.4p2.3p2.2p2.1p2.011111111 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: (bit addressable) 0xa0 bits7 C 6: unused. read = 00b. write = don t care. bits5 C 0: output configuration bit for p2.5 C 2.0: 0: p2.0 output is open-drain. 1: p2.0 output is push-pull. r/wr/wr/wr/wr/wr/wr/wr/wreset value 00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0xa6 bits7 C 1:unused. read = 0000000b. write = don t care. bit0:p3.0 write - output appears on i/o pins. 0: logic low output. 1: logic high output (high impedance if corresponding p3mdout.n bit = 0). read - always reads 0 if inputen = 0 . otherwise, directly reads port pin. 0: p3.n pin is logic low. 1: p3.n pin is logic high. r/wr/wr/wr/wr/wr/wr/wr/wreset value p3.011111111 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: (bit addressable) 0xb0
C8051F326/7 86rev. 0.5 sfr definition11.7.p3mdout: port3 output mode bits7 C 1: unused. read = 0000000b. write = don t care. bit0: output configuration bit for p3.0: 0: p3.0 output is open-drain. 1: p3.0 output is push-pull. r/wr/wr/wr/wr/wr/wr/wr/wreset value 00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0xa7
rev. 0.587 C8051F326/7 table11.1.port i/o dc electrical characteristics (C8051F326) vdd = 2.7 to 3.6 v, C 40 to +85 c unless otherwise specified parameter conditions min typ max units vio = 2.7 to 3.6v output high voltage ioh = C 10 a; port i/o push-pull ioh = C 3 ma; port i/o push-pull ioh = C 10 ma; port i/o push-pull vio C 0.1 vio C 0.7 vio C 0.8 v output low voltage i ol = 10 a iol = 8.5 ma iol = 25 ma 1.0 0.1 0.6 v input high voltage 2.0 v input low voltage 0.8 v input leakage currentweak pullup off weak pullup on, v in = 0v 25 1 50 a vio = 1.8 v output high voltage ioh = C 10 a; port i/o push-pull ioh = C 1 ma; port i/o push-pull vio C 0.1 vio C 0.4 v output low voltage i ol = 10 a iol = 3 ma 0.1 0.4 v input high voltage vdd x 0.7 v input low voltage vdd x 0.3 v input leakage currentweak pullup off weak pullup on, v in = 0v 6 1 15 a table11.2.port i/o dc electrical characteristics (c8051f327) vdd = 2.7 to 3.6v, C 40 to +85 c unless otherwise specified parameter conditions min typ max units output high voltage ioh = C 10 a; port i/o push-pull ioh = C 3 ma; port i/o push-pull ioh = C 10 ma; port i/o push-pull vdd C 0.1 vdd C 0.7 vdd C 0.8 v output low voltage i ol = 10 a iol = 8.5 ma iol = 25 ma 1.0 0.1 0.6 v input high voltage 2.0 v input low voltage 0.8 v input leakage currentweak pullup off weak pullup on, v in = 0v 25 1 50 a
C8051F326/7 88rev. 0.5 n otes :
rev. 0.589 C8051F326/7 12.universal serial bus controller (usb0) C8051F326/7 devices include a complete full/low speed usb function for usb peripheral implementa- tions*. the usb function controller (usb0) consists of a serial interface engine (sie), usb transceiver (including matching resistors and configurable pullup resistors), 256 byte fifo block, and clock recovery mechanism for crystal-less operation. no external components are required. the usb function controller and transceiver is universal serial bus specification 2.0 compliant. *note: the C8051F326/7 cannot be used as a usb host device. figure 12.1. usb0 block diagram important note: this document assumes a comprehensive understanding of the usb protocol. terms and abbreviations used in this document are defined in the usb specification. we encourage you to review the latest version of the usb specification before proceeding. transceiver serial interface engine (sie) usb fifos (256b ram) d+ d- vdd endpoint0 in/out endpoint1 in out data transfer control cip-51 core usb control, status, and interrupt registers
C8051F326/7 90rev. 0.5 12.1.endpoint addressing a total of three endpoint pipes are available. the control endpoint (endpoint0) always functions as a bi-directional in/out endpoint. endpoint 1 is implemented as a 64 byte in pipe and a 128 byte out pipe: 12.2.usb transceiver the usb transceiver is configured via the usb0xcn register shown in figure12.1. this configuration includes transceiver enable/disable, pullup resistor enable/disable, and device speed selection (full or low speed). when bit speed = 1 , usb0 operates as a full speed usb function, and the on-chip pullup resistor (if enabled) appears on the d+ pin. when bit speed = 0 , usb0 operates as a low speed usb function, and the on-chip pullup resistor (if enabled) appears on the d- pin. bits4-0 of register usb0xcn can be used for transceiver testing as described in figure12.1. the pullup resistor is enabled only when vbus is present (see section 5.2.vbus detection on page33 for details on vbus detection). important note: the usb clock should be active before the transceiver is enabled. table12.1.endpoint addressing scheme endpoint associated pipes usb protocol address endpoint0 endpoint0 in 0x00 endpoint0 out 0x00 endpoint1 endpoint1 in 0x81 endpoint1 out 0x01
rev. 0.591 C8051F326/7 usb register definition12.1.usb0xcn: usb0 transceiver control bit7:pren: internal pullup resistor enable the location of the pullup resistor (d+ or d-) is determined by the speed bit. 0: internal pullup resistor disabled (device effectively detached from the usb network). 1: internal pullup resistor enabled when vbus is present (device attached to the usb net- work). bit6:phyen: physical layer enable this bit enables/disables the usb0 physical layer transceiver. 0: transceiver disabled (suspend). 1: transceiver enabled (normal). bit5:speed: usb0 speed select this bit selects the usb0 speed. 0: usb0 operates as a low speed device. if enabled, the internal pullup resistor appears on the d- line. 1: usb0 operates as a full speed device. if enabled, the internal pullup resistor appears on the d+ line. bits4 C 3:phytst1-0: physical layer test these bits can be used to test the usb0 transceiver. bit2:dfrec: differential receiver the state of this bit indicates the current differential value present on the d+ and d- lines when phyen = 1 . 0: differential 0 signaling on the bus. 1: differential 1 signaling on the bus. bit1:dp: d+ signal status this bit indicates the current logic level of the d+ pin. 0: d+ signal currently at logic 0. 1: d+ signal currently at logic 1. bit0:dn: d- signal status this bit indicates the current logic level of the d- pin. 0: d- signal currently at logic 0. 1: d- signal currently at logic 1. r/wr/wr/wr/wr/wrrrreset value prenphyenspeedphytst1phytst0dfrecdpdn00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0xd7 phytst[1:0]moded+d C 00bmode 0: normal (non-test mode)xx 01bmode 1: differential 1 forced10 10bmode 2: differential 0 forced01 11bmode 3: single-ended 0 forced00
C8051F326/7 92rev. 0.5 12.3.usb register access the usb0 controller registers listed in table12.2 are accessed through two sfrs: usb0 address (usb0adr) and usb0 data (usb0dat). the usb0adr register selects which usb register is targeted by reads/writes of the usb0dat register. see figure12.2. endpoint control/status registers are accessed by first writing the usb register index with the target end- point number. once the target endpoint number is written to the index register, the control/status registers associated with the target endpoint may be accessed. see the indexed registers section of table12.2 for a list of endpoint control/status registers. important note: the usb clock must be active when accessing usb registers. figure 12.2. usb0 register access scheme usb controller fifo access index register endpoint0 control/ status registers endpoint1 control/ status registers common registers interrupt registers 8051 sfrs usb0adr usb0dat
rev. 0.593 C8051F326/7 usb register definition12.2.usb0adr: usb0 indirect address bits7: busy: usb0 register read busy flag this bit is used during indirect usb0 register accesses. software should write 1 to this bit to initiate a read of the usb0 register targeted by the usbaddr bits (usb0adr.[5-0]). the target address and busy bit may be written in the same write to usb0adr. after busy is set to 1 , hardware will clear busy when the targeted register data is ready in the usb0dat register. software should check busy for 0 before writing to usb0dat. write: 0: no effect. 1: a usb0 indirect register read is initiated at the address specified by the usbaddr bits. read: 0: usb0dat register data is valid. 1: usb0 is busy accessing an indirect register; usb0dat register data is invalid. bit6:autord: usb0 register auto-read flag this bit is used for block fifo reads. 0: busy must be written manually for each usb0 indirect register read. 1: the next indirect register read will automatically be initiated when software reads usb0dat (usbaddr bits will not be changed). bits5 C 0:usbaddr: usb0 indirect register address these bits hold a 6-bit address used to indirectly access the usb0 core registers. table 12.2 lists the usb0 core registers and their indirect addresses. reads and writes to usb0dat will target the register indicated by the usbaddr bits. r/wr/wr/wr/wr/wr/wr/wr/wreset value busyautordusbaddr00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0x96
C8051F326/7 94rev. 0.5 usb register definition12.3.usb0dat: usb0 data usb register definition12.4.index: usb0 endpoint index this sfr is used to indirectly read and write usb0 registers. write procedure: 1. poll for busy (usb0adr.7) => 0 . 2. load the target usb0 register address into the usbaddr bits in register usb0adr. 3. write data to usb0dat. 4. repeat (step 2 may be skipped when writing to the same usb0 register). read procedure: 1. poll for busy (usb0adr.7) => 0 . 2. load the target usb0 register address into the usbaddr bits in register usb0adr. 3. write 1 to the busy bit in register usb0adr (steps 2 and 3 can be performed in the same write). 4. poll for busy (usb0adr.7) => 0 . 5. read data from usb0dat. 6. repeat from step 2 (step 2 may be skipped when reading the same usb0 register; step 3 may be skipped when the autord bit (usb0adr.6) is logic 1). r/wr/wr/wr/wr/wr/wr/wr/wreset value usb0dat00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0x97 bits7 C 4: unused. read = 0000b; write = don t care. bits3 C 0:epsel: endpoint select these bits select which endpoint is targeted when indexed usb0 registers are accessed. rrrrr/wr/wr/wr/wreset value epsel00000000 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x0e indextarget endpoint 0x00 0x11 0x2 C 0xfreserved
rev. 0.595 C8051F326/7 table12.2.usb0 controller registers usb register name usb register address description page number interrupt registers in1int 0x02 endpoint0 and endpoint1 in interrupt flags 103 out1int 0x04 endpoint1 out interrupt flag 103 cmint 0x06 common usb interrupt flags 104 in1ie 0x07 endpoint0 and endpoint1 in interrupt enables 104 out1ie 0x09 endpoint1 out interrupt enable 105 cmie 0x0b common usb interrupt enable 105 common registers faddr 0x00 function address 99 power 0x01 power management 101 framel 0x0c frame number low byte 102 frameh 0x0d frame number high byte 102 index 0x0e endpoint index selection 94 clkrec 0x0f clock recovery control 96 fifon 0x20-0x21 endpoints0-1 fifos 98 indexed registers e0csr 0x11 endpoint0 control / status 108 eincsrl endpoint in control / status low byte 112 eincsrh 0x12 endpoint in control / status high byte 113 eoutcsrl 0x14 endpoint out control / status low byte 115 eoutcsrh 0x15 endpoint out control / status high byte 116 e0cnt 0x16 number of received bytes in endpoint0 fifo 109 eoutcntl endpoint out packet count low byte 116 eoutcnth 0x17 endpoint out packet count high byte 116
C8051F326/7 96rev. 0.5 12.4.usb clock configuration usb0 is capable of communication as a full or low speed usb function. communication speed is selected via the speed bit in sfr usb0xcn. when operating as a low speed function, the usb0 clock must be 6mhz. when operating as a full speed function, the usb0 clock must be 48mhz. clock options are described in section 10.oscillators on page73 . the usb0 clock is selected via sfr clksel (see figure10.5 on page79). the usb transceiver must be enabled before enabling clock recovery. clock recovery circuitry uses the incoming usb data stream to adjust the internal oscillator; this allows the internal oscillator (and 4x clock multiplier) to meet the requirements for usb clock tolerance. clock recovery should be used in the following configurations: when operating usb0 as a low speed function with clock recovery, software must write 1 to the crlow bit to enable low speed clock recovery. clock recovery is typically not necessary in low speed mode. single step mode can be used to help the clock recovery circuitry to lock when high noise levels are present on the usb network. this mode is not required (or recommended) in typical usb environments. usb register definition12.5.clkrec: clock recovery control communication speedusb clock4x clock multiplier input full speed4x clock multiplierinternal oscillator low speedinternal oscillator/2n/a bit7:cre: clock recovery enable. this bit enables/disables the usb clock recovery feature. 0: clock recovery disabled. 1: clock recovery enabled. bit6:crssen: clock recovery single step. this bit forces the oscillator calibration into single-step mode during clock recovery. 0: normal calibration mode. 1: single step mode. bit5:crlow: low speed clock recovery mode. this bit must be set to 1 if clock recovery is used when operating as a low speed usb device. 0: full speed mode. 1: low speed mode. bits4 C 0:reserved. read = variable. must write = 01001b. r/wr/wr/wr/wr/wr/wr/wr/wreset value crecrssencrlowreserved00001001 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x0f
rev. 0.597 C8051F326/7 12.5.fifo management 256 bytes of on-chip xram are used as fifo space for usb0. this fifo space is split between endpoint0 and endpoint1 as shown in figure12.3. fifo space allocated for endpoint1 is split into an in and an out endpoint. figure 12.3. usb fifo allocation 12.5.1.fifo split mode the fifo space for endpoint1 is split such that the upper 64 bytes of the fifo space is used by the in endpoint, and the lower 128 bytes is used by the out endpoint. the fifo space for endpoint0 is not split. the 64 byte fifo space forms a single in or out fifo. endpoint0 can transfer data in one direction at a time. the endpoint direction (in/out) is determined by the dirsel bit in the corresponding endpoint s eincsrh register (see figure12.20). 12.5.2.fifo double buffering the endpoint1 fifo can be configured for double-buffered mode. in this mode, the maximum packet size is halved and the fifo may contain two packets at a time. this mode is only available for endpoint1. dou- ble buffering may be enabled for the in endpoint and/or the out endpoint. see table12.3 for a list of maximum packet sizes for each fifo configuration. table12.3.fifo configurations endpoint number split mode enabled? maximum in packet size (double buffer disabled / enabled) maximum out packet size (double buffer dis- abled / enabled) 0n/a64 1y64 / 32128 / 64 user xram (1024 bytes) 0x0000 0x03ff usb clock domain system clock domain endpoint0 (64 bytes) 0x00 0xbf 0xc0 0xff endpoint1 in (64 bytes) out (128 bytes) endpoint1 (split in/out) endpoint0 (in/out) control endpoint
C8051F326/7 98rev. 0.5 12.5.1.fifo access each endpoint fifo is accessed through a corresponding fifon register. a read of an endpoint fifon register unloads one byte from the fifo; a write of an endpoint fifon register loads one byte into the end- point fifo. when an endpoint fifo is configured for split mode, a read of the endpoint fifon register unloads one byte from the out endpoint fifo; a write of the endpoint fifon register loads one byte into the in endpoint fifo. usb register definition12.6.fifon: usb0 endpoint fifo access usb addresses 0x20 C 0x21 provide access to the 2 pairs of endpoint fifos: writing to the fifo address loads data into the in fifo for the corresponding endpoint. reading from the fifo address unloads data from the out fifo for the corresponding endpoint. r/wr/wr/wr/wr/wr/wr/wr/wreset value fifodata00000000 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x20 C 0x21 in/out endpoint fifousb address 00x20 10x21
rev. 0.599 C8051F326/7 12.6.function addressing the faddr register holds the current usb0 function address. software should write the host-assigned 7-bit function address to the faddr register when received as part of a set_address command. a new address written to faddr will not take effect (usb0 will not respond to the new address) until the end of the current transfer (typically following the status phase of the set_address command transfer). the update bit (faddr.7) is set to 1 by hardware when software writes a new address to the faddr regis- ter. hardware clears the update bit when the new address takes effect as described above. usb register definition12.7.faddr: usb0 function address bit7:update: function address update set to 1 when software writes the faddr register. usb0 clears this bit to 0 when the new address takes effect. 0: the last address written to faddr is in effect. 1: the last address written to faddr is not yet in effect. bits6 C 0:function address holds the 7-bit function address for usb0. this address should be written by software when the set_address standard device request is received on endpoint0. the new address takes effect when the device request completes. rr/wr/wr/wr/wr/wr/wr/wreset value updatefunction address00000000 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x00
C8051F326/7 100rev. 0.5 12.7.function configuration and control the usb register power (figure12.8) is used to configure and control usb0 at the device level (enable/ disable, reset/suspend/resume handling, etc.). usb reset: the usbrst bit (power.3) is set to 1 by hardware when reset signaling is detected on the bus. upon this detection, the following occur: 1.the usb0 address is reset (faddr = 0x00). 2.endpoint fifos are flushed. 3.control/status registers are reset to 0x00 (e0csr, eincsrl, eincsrh, eoutcsrl, eoutcsrh). 4.usb register index is reset to 0x00. 5.all usb interrupts (excluding the suspend interrupt) are enabled and their corresponding flags cleared. 6.a usb reset interrupt is generated if enabled. writing a 1 to the usbrst bit will generate an asynchronous usb0 reset. all usb registers are reset to their default values following this asynchronous reset. suspend mode: with suspend detection enabled (susen = 1 ), usb0 will enter suspend mode when suspend signaling is detected on the bus. an interrupt will be generated if enabled (susinte = 1 ). the suspend interrupt service routine (isr) should perform application-specific configuration tasks such as disabling appropriate peripherals and/or configuring clock sources for low power modes. see section 10.oscillators on page73 for more details on internal oscillator configuration, including the suspend mode feature of the internal oscillator. usb0 exits suspend mode when any of the following occur: (1) resume signaling is detected or gener- ated, (2) reset signaling is detected, or (3) a device or usb reset occurs. if suspended, the internal oscil- lator will exit suspend mode upon any of the above listed events. resume signaling: usb0 will exit suspend mode if resume signaling is detected on the bus. a resume interrupt will be generated upon detection if enabled (resinte = 1 ). software may force a remote wakeup by writing 1 to the resume bit (power.2). when forcing a remote wakeup, software should write resume = 0 to end resume signaling 10-15ms after the remote wakeup is initiated (resume = 1 ). iso update: when software writes 1 to the isoup bit (power.7), the iso update function is enabled. with iso update enabled, new packets written to an iso in endpoint will not be transmitted until a new start-of-frame (sof) is received. if the iso in endpoint receives an in token before a sof, usb0 will transmit a zero-length packet. when isoup = 1 , iso update is enabled for all iso endpoints. usb enable: usb0 is disabled following a power-on-reset (por). usb0 is enabled by clearing the usbinh bit (power.4). once written to 0 , the usbinh can only be set to 1 by one of the following: (1) a power-on-reset (por), or (2) an asynchronous usb0 reset generated by writing 1 to the usbrst bit (power.3). software should perform all usb0 configuration before enabling usb0. the configuration sequence should be performed as follows: step 1. select and enable the usb clock source. step 2. reset usb0 by writing usbrst= 1 . step 3. configure and enable the usb transceiver. step 4. perform any usb0 function configuration (interrupts, suspend detect). step 5. enable usb0 by writing usbinh = 0 .
rev. 0.5101 C8051F326/7 usb register definition12.8.power: usb0 power bit7:isoud: iso update this bit affects all in isochronous endpoints. 0: when software writes inprdy = 1 , usb0 will send the packet when the next in token is received. 1: when software writes inprdy = 1 , usb0 will wait for a sof token before sending the packet. if an in token is received before a sof token, usb0 will send a zero-length data packet. bits6 C 5:unused. read = 00b. write = don t care. bit4:usbinh: usb0 inhibit this bit is set to 1 following a power-on reset (por) or an asynchronous usb0 reset (see bit3: reset). software should clear this bit after all usb0 and transceiver initialization is complete. software cannot set this bit to 1 . 0: usb0 enabled. 1: usb0 inhibited. all usb traffic is ignored. bit3:usbrst: reset detect writing 1 to this bit forces an asynchronous usb0 reset. reading this bit provides bus reset status information. read: 0: reset signaling is not present on the bus. 1: reset signaling detected on the bus. bit2:resume: force resume software can force resume signaling on the bus to wake usb0 from suspend mode. writing a 1 to this bit while in suspend mode (susmd = 1 ) forces usb0 to generate resume sig- naling on the bus (a remote wakeup event). software should write resume = 0 after 10 ms to15 ms to end the resume signaling. an interrupt is generated, and hardware clears susmd, when software writes resume = 0 . bit1:susmd: suspend mode set to 1 by hardware when usb0 enters suspend mode. cleared by hardware when soft- ware writes resume = 0 (following a remote wakeup) or reads the cmint register after detection of resume signaling on the bus. 0: usb0 not in suspend mode. 1: usb0 in suspend mode. bit0:susen: suspend detection enable 0: suspend detection disabled. usb0 will ignore suspend signaling on the bus. 1: suspend detection enabled. usb0 will enter suspend mode if it detects suspend signaling on the bus. r/wr/wr/wr/wr/wr/wrr/wreset value isoud--usbinhusbrstresumesusmdsusen00010000 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x01
C8051F326/7 102rev. 0.5 usb register definition12.9.framel: usb0 frame number low usb register definition12.10.frameh: usb0 frame number high bits7 C 0: frame number low this register contains bits7-0 of the last received frame number. rrrrrrrrreset value frame number low00000000 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x0c bits7 C 3:unused. read = 0. write = don t care. bits2 C 0: frame number high byte this register contains bits10-8 of the last received frame number. rrrrrrrrreset value frame number high00000000 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x0d
rev. 0.5103 C8051F326/7 12.8.interrupts the read-only usb0 interrupt flags are located in the usb registers shown in figure12.11 through figure12.13. the associated interrupt enable bits are located in the usb registers shown in figure12.14 through figure12.16. a usb0 interrupt is generated when any of the usb interrupt flags is set to 1 . the usb0 interrupt is enabled via the eie1 sfr (see section 6.3.interrupt handler on page50 ). important note: reading a usb interrupt flag register resets all flags in that register to 0 . usb register definition12.11.in1int: usb0 in endpoint interrupt usb register definition12.12.out1int: usb0 out endpoint interrupt bits7 C 2:unused. read = 000000b. write = don t care. bit1:in1: in endpoint 1 interrupt-pending flag this bit is cleared when software reads the in1int register. 0: in endpoint 1 interrupt inactive. 1: in endpoint 1 interrupt active. bit0:ep0: endpoint 0 interrupt-pending flag this bit is cleared when software reads the in1int register. 0: endpoint 0 interrupt inactive. 1: endpoint 0 interrupt active. rrrrrrrrreset value in1ep000000000 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x02 bits7 C 2:unused. read = 000000b. write = don t care. bit1:out1: out endpoint 1 interrupt-pending flag this bit is cleared when software reads the out1int register. 0: out endpoint 1 interrupt inactive. 1: out endpoint 1 interrupt active. bit0:unused. read = 0; write = don t care. rrrrrrrrreset value out1 00000000 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x04
C8051F326/7 104rev. 0.5 usb register definition12.13.cmint: usb0 common interrupt usb register definition12.14.in1ie: usb0 in endpoint interrupt enable bits7 C 4:unused. read = 0000b; write = don t care. bit3:sof: start of frame interrupt set by hardware when a sof token is received. this interrupt event is synthesized by hard- ware: an interrupt will be generated when hardware expects to receive a sof event, even if the actual sof signal is missed or corrupted. this bit is cleared when software reads the cmint register. 0: sof interrupt inactive. 1: sof interrupt active. bit2:rstint: reset interrupt-pending flag set by hardware when reset signaling is detected on the bus. this bit is cleared when software reads the cmint register. 0: reset interrupt inactive. 1: reset interrupt active. bit1:rsuint: resume interrupt-pending flag set by hardware when resume signaling is detected on the bus while usb0 is in suspend mode. this bit is cleared when software reads the cmint register. 0: resume interrupt inactive. 1: resume interrupt active. bit0:susint: suspend interrupt-pending flag when suspend detection is enabled (bit susen in register power), this bit is set by hard- ware when suspend signaling is detected on the bus. this bit is cleared when software reads the cmint register. 0: suspend interrupt inactive. 1: suspend interrupt active. rrrrrrrrreset value sofrstintrsuintsusint00000000 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x06 bits7 C 2:unused. read = 000000b. write = don t care. bit1:in1e: in endpoint 1 interrupt enable 0: in endpoint 1 interrupt disabled. 1: in endpoint 1 interrupt enabled. bit0:ep0e: endpoint 0 interrupt enable 0: endpoint 0 interrupt disabled. 1: endpoint 0 interrupt enabled. r/wr/wr/wr/wr/wr/wr/wr/wreset value in1eep0e00000011 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x07
rev. 0.5105 C8051F326/7 usb register definition12.15.out1ie: usb0 out endpoint interrupt enable usb register definition12.16.cmie: usb0 common interrupt enable bits7 C 2:unused. read = 000000b. write = don t care. bit1:out1e: out endpoint 1 interrupt enable 0: out endpoint 1 interrupt disabled. 1: out endpoint 1 interrupt enabled. bit0:unused. read = 0; write = don t care. r/wr/wr/wr/wr/wr/wr/wr/wreset value out1e 00000010 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x09 bits7 C 4:unused. read = 0000b; write = don t care. bit3:sofe: start of frame interrupt enable 0: sof interrupt disabled. 1: sof interrupt enabled. bit2:rstinte: reset interrupt enable 0: reset interrupt disabled. 1: reset interrupt enabled. bit1:rsuinte: resume interrupt enable 0: resume interrupt disabled. 1: resume interrupt enabled. bit0:susinte: suspend interrupt enable 0: suspend interrupt disabled. 1: suspend interrupt enabled. r/wr/wr/wr/wr/wr/wr/wr/wreset value soferstintersuintesusinte00000110 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x0b
C8051F326/7 106rev. 0.5 12.9.the serial interface engine the serial interface engine (sie) performs all low level usb protocol tasks, interrupting the processor when data has successfully been transmitted or received. when receiving data, the sie will interrupt the processor when a complete data packet has been received; appropriate handshaking signals are automat- ically generated by the sie. when transmitting data, the sie will interrupt the processor when a complete data packet has been transmitted and the appropriate handshake signal has been received. the sie will not interrupt the processor when corrupted/erroneous packets are received. 12.10.endpoint0 endpoint0 is managed through the usb register e0csr (figure12.17). the index register must be loaded with 0x00 to access the e0csr register. an endpoint0 interrupt is generated when: 1.a data packet (out or setup) has been received and loaded into the endpoint0 fifo. the oprdy bit (e0csr.0) is set to 1 by hardware. 2.an in data packet has successfully been unloaded from the endpoint0 fifo and transmitted to the host; inprdy is reset to 0 by hardware. 3.an in transaction is completed (this interrupt generated during the status stage of the transac- tion). 4.hardware sets the ststl bit (e0csr.2) after a control transaction ended due to a protocol violation. 5.hardware sets the suend bit (e0csr.4) because a control transfer ended before firmware sets the dataend bit (e0csr.3). the e0cnt register (figure12.18) holds the number of received data bytes in the endpoint0 fifo. hardware will automatically detect protocol errors and send a stall condition in response. firmware may force a stall condition to abort the current transfer. when a stall condition is generated, the ststl bit will be set to 1 and an interrupt generated. the following conditions will cause hardware to generate a stall condition: 1.the host sends an out token during a out data phase after the dataend bit has been set to 1 . 2.the host sends an in token during an in data phase after the dataend bit has been set to 1 . 3.the host sends a packet that exceeds the maximum packet size for endpoint0. 4.the host sends a non-zero length data1 packet during the status phase of an in transaction. firmware sets the sdstl bit (e0csr.5) to 1 . 12.10.1.endpoint0 setup transactions all control transfers must begin with a setup packet. setup packets are similar to out packets, contain- ing an 8-byte data field sent by the host. any setup packet containing a command field of anything other than 8 bytes will be automatically rejected by usb0. an endpoint0 interrupt is generated when the data from a setup packet is loaded into the endpoint0 fifo. software should unload the command from the endpoint0 fifo, decode the command, perform any necessary tasks, and set the soprdy bit to indicate that it has serviced the out packet.
rev. 0.5107 C8051F326/7 12.10.2.endpoint0 in transactions when a setup request is received that requires usb0 to transmit data to the host, one or more in requests will be sent by the host. for the first in transaction, firmware should load an in packet into the endpoint0 fifo, and set the inprdy bit (e0csr.1). an interrupt will be generated when an in packet is transmitted successfully. note that no interrupt will be generated if an in request is received before firm- ware has loaded a packet into the endpoint0 fifo. if the requested data exceeds the maximum packet size for endpoint0 (as reported to the host), the data should be split into multiple packets; each packet should be of the maximum packet size excluding the last (residual) packet. if the requested data is an inte- ger multiple of the maximum packet size for endpoint0, the last data packet should be a zero-length packet signaling the end of the transfer. firmware should set the dataend bit to 1 after loading into the endpoint0 fifo the last data packet for a transfer. upon reception of the first in token for a particular control transfer, endpoint0 is said to be in transmit mode. in this mode, only in tokens should be sent by the host to endpoint0. the suend bit (e0csr.4) is set to 1 if a setup or out token is received while endpoint0 is in transmit mode. endpoint0 will remain in transmit mode until any of the following occur: 1.usb0 receives an endpoint0 setup or out token. 2.firmware sends a packet less than the maximum endpoint0 packet size. 3.firmware sends a zero-length packet. firmware should set the dataend bit (e0csr.3) to 1 when performing (2) and (3) above. the sie will transmit a nak in response to an in token if there is no packet ready in the in fifo (inprdy= 0 ). 12.10.3.endpoint0 out transactions when a setup request is received that requires the host to transmit data to usb0, one or more out requests will be sent by the host. when an out packet is successfully received by usb0, hardware will set the oprdy bit (e0csr.0) to 1 and generate an endpoint0 interrupt. following this interrupt, firmware should unload the out packet from the endpoint0 fifo and set the soprdy bit (e0csr.6) to 1 . if the amount of data required for the transfer exceeds the maximum packet size for endpoint0, the data will be split into multiple packets. if the requested data is an integer multiple of the maximum packet size for endpoint0 (as reported to the host), the host will send a zero-length data packet signaling the end of the transfer. upon reception of the first out token for a particular control transfer, endpoint0 is said to be in receive mode. in this mode, only out tokens should be sent by the host to endpoint0. the suend bit (e0csr.4) is set to 1 if a setup or in token is received while endpoint0 is in receive mode. endpoint0 will remain in receive mode until: 1.the sie receives a setup or in token. 2.the host sends a packet less than the maximum endpoint0 packet size. 3.the host sends a zero-length packet. firmware should set the dataend bit (e0csr.3) to 1 when the expected amount of data has been received. the sie will transmit a stall condition if the host sends an out packet after the dataend bit has been set by firmware. an interrupt will be generated with the ststl bit (e0csr.2) set to 1 after the stall is transmitted.
C8051F326/7 108rev. 0.5 usb register definition12.17.e0csr: usb0 endpoint0 control bit7:ssuend: serviced setup end write: software should set this bit to 1 after servicing a setup end (bit suend) event. hardware clears the suend bit when software writes 1 to ssuend. read: this bit always reads 0 . bit6:soprdy: serviced oprdy write: software should write 1 to this bit after servicing a received endpoint0 packet. the oprdy bit will be cleared by a write of 1 to soprdy. read: this bit always reads 0 . bit5:sdstl: send stall software can write 1 to this bit to terminate the current transfer (due to an error condition, unexpected transfer request, etc.). hardware will clear this bit to 0 when the stall hand- shake is transmitted. bit4:suend: setup end hardware sets this read-only bit to 1 when a control transaction ends before software has written 1 to the dataend bit. hardware clears this bit when software writes 1 to ssuend. bit3:dataend: data end software should write 1 to this bit: 1. when writing 1 to inprdy for the last outgoing data packet. 2. when writing 1 to inprdy for a zero-length data packet. 3. when writing 1 to soprdy after servicing the last incoming data packet. this bit is automatically cleared by hardware. bit2:ststl: sent stall hardware sets this bit to 1 after transmitting a stall handshake signal. this flag must be cleared by software. bit1:inprdy: in packet ready software should write 1 to this bit after loading a data packet into the endpoint0 fifo for transmit. hardware clears this bit and generates an interrupt under either of the following conditions: 1. the packet is transmitted. 2. the packet is overwritten by an incoming setup packet. 3. the packet is overwritten by an incoming out packet. bit0:oprdy: out packet ready hardware sets this read-only bit and generates an interrupt when a data packet has been received. this bit is cleared only when software writes 1 to the soprdy bit. r/wr/wr/wrr/wr/wr/wrreset value ssuendsoprdysdstlsuenddataendststlinprdyoprdy00000000 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x11
rev. 0.5109 C8051F326/7 usb register definition12.18.e0cnt: usb0 endpoint 0 data count bit7:unused. read = 0; write = don t care. bits6 C 0:e0cnt: endpoint 0 data count this 7-bit number indicates the number of received data bytes in the endpoint 0 fifo. this number is only valid while bit oprdy is a 1 . rrrrrrrrreset value -e0cnt00000000 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x16
C8051F326/7 110rev. 0.5 12.11.configuring endpoint1 endpoint1 is configured and controlled through a set of control/status registers: in registers eincsrl and eincsrh, and out registers eoutcsrl and eoutcsrh. the endpoint control/status registers are mapped into the usb register address space based on the contents of the index register (figure12.4). 12.12.controlling endpoint1 in endpoint1 in is managed via usb registers eincsrl and eincsrh. the in endpoint can be used for interrupt, bulk, or isochronous transfers. isochronous (iso) mode is enabled by writing 1 to the iso bit in register eincsrh. bulk and interrupt transfers are handled identically by hardware. an endpoint1 in interrupt is generated by any of the following conditions: 1.an in packet is successfully transferred to the host. 2.software writes 1 to the flush bit (eincsrl.3) when the target fifo is not empty. 3.hardware generates a stall condition. 12.12.1.endpoint1 in interrupt or bulk mode when the iso bit (eincsrh.6) is logic 0, endpoint1 operates in bulk or interrupt mode. once it has been configured to operate in bulk/interrupt in mode (typically following an endpoint0 set_interface com- mand), firmware should load an in packet into the endpoint in fifo and set the inprdy bit (eincsrl.0). upon reception of an in token, hardware will transmit the data, clear the inprdy bit, and generate an interrupt. writing 1 to inprdy without writing any data to the endpoint fifo will cause a zero-length packet to be transmitted upon reception of the next in token. a bulk or interrupt pipe can be shut down (or halted) by writing 1 to the sdstl bit (eincsrl.4). while sdstl= 1 , hardware will respond to all in requests with a stall condition. each time hardware gener- ates a stall condition, an interrupt will be generated and the ststl bit (eincsrl.5) set to 1 . the ststl bit must be reset to 0 by firmware. hardware will automatically reset inprdy to 0 when a packet slot is open in the endpoint fifo. if double buffering is enabled for the target endpoint, it is possible for firmware to load two packets into the in fifo at a time. in this case, hardware will reset inprdy to 0 immediately after firmware loads the first packet into the fifo and sets inprdy to 1 . an interrupt will not be generated in this case; an interrupt will only be generated when a data packet is transmitted. when firmware writes 1 to the fcdt bit (eincsrh.3), the data toggle for each in packet will be toggled continuously, regardless of the handshake received from the host. this feature is typically used by inter- rupt endpoints functioning as rate feedback communication for isochronous endpoints. when fcdt = 0 , the data toggle bit will only be toggled when an ack is sent from the host in response to an in packet. 12.12.2.endpoint1 in isochronous mode when the iso bit (eincsrh.6) is set to 1 , the target endpoint operates in isochronous (iso) mode. once an endpoint has been configured for iso in mode, the host will send one in token (data request) per frame; the location of data within each frame may vary. therefore, it is recommended that double buffering be enabled when using endpoint1 in as an isochronous endpoint.
rev. 0.5111 C8051F326/7 hardware will automatically reset inprdy (eincsrl.0) to 0 when a packet slot is open in the endpoint fifo. note that if double buffering is enabled for the endpoint, it is possible for firmware to load two pack- ets into the in fifo at a time. in this case, hardware will reset inprdy to 0 immediately after firmware loads the first packet into the fifo and sets inprdy to 1 . an interrupt will not be generated in this case; an interrupt will only be generated when a data packet is transmitted. if there is not a data packet ready in the endpoint fifo when usb0 receives an in token from the host, usb0 will transmit a zero-length data packet and set the undrun bit (eincsrl.2) to 1 . the iso update feature (see section 12.7 ) can be useful in starting a double buffered iso in endpoint. if the host has already set up the iso in pipe (has begun transmitting in tokens) when firmware writes the first data packet to the endpoint fifo, the next in token may arrive and the first data packet sent before firmware has written the second (double buffered) data packet to the fifo. the iso update feature ensures that any data packet written to the endpoint fifo will not be transmitted during the current frame; the packet will only be sent after a sof signal has been received.
C8051F326/7 112rev. 0.5 usb register definition12.19.eincsrl: usb0 in endpoint control low byte bit7:unused. read = 0; write = don t care. bit6:clrdt: clear data toggle. write: software should write 1 to this bit to reset the in endpoint data toggle to 0 . read: this bit always reads 0 . bit5:ststl: sent stall hardware sets this bit to 1 when a stall handshake signal is transmitted. the fifo is flushed, and the inprdy bit cleared. this flag must be cleared by software. bit4:sdstl: send stall. software should write 1 to this bit to generate a stall handshake in response to an in token. software should write 0 to this bit to terminate the stall signal. this bit has no effect in iso mode. bit3:flush: fifo flush. writing a 1 to this bit flushes the next packet to be transmitted from the in endpoint fifo. the fifo pointer is reset and the inprdy bit is cleared. if the fifo contains multiple pack- ets, software must write 1 to flush for each packet. hardware resets the flush bit to 0 when the fifo flush is complete. bit2:undrun: data underrun. the function of this bit depends on the in endpoint mode: iso: set when a zero-length packet is sent after an in token is received while bit inprdy = 0 . interrupt/bulk: set when a nak is returned in response to an in token. this bit must be cleared by software. bit1:fifone: fifo not empty. 0: the in endpoint fifo is empty. 1. the in endpoint fifo contains one or more packets. bit0:inprdy: in packet ready. software should write 1 to this bit after loading a data packet into the in endpoint fifo. hardware clears inprdy due to any of the following: 1. a data packet is transmitted. 2. double buffering is enabled (dbien = 1 ) and there is an open fifo packet slot. 3. if the endpoint is in isochronous mode (iso = 1 ) and isoud = 1 , inprdy will read 0 until the next sof is received. an interrupt (if enabled) will be generated when hardware clears inprdy as a result of a packet being transmitted. rwr/wr/wr/wr/wr/wr/wreset value clrdtststlsdstlflushundrunfifoneinprdy00000000 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x11
rev. 0.5113 C8051F326/7 usb register definition12.20.eincsrh: usb0 in endpoint control high byte bit7:dbien: in endpoint double-buffer enable. 0: double-buffering disabled for the selected in endpoint. 1: double-buffering enabled for the selected in endpoint. bit6:iso: isochronous transfer enable. this bit enables/disables isochronous transfers on the current endpoint. 0: endpoint configured for bulk/interrupt transfers. 1: endpoint configured for isochronous transfers. bit5 C 4:unused. read = 00b. write = don t care. bit3:fcdt: force data toggle. 0: endpoint data toggle switches only when an ack is received following a data packet transmission. 1: endpoint data toggle forced to switch after every data packet is transmitted, regardless of ack reception. bits2-0:unused. read = 000b; write = don t care. r/wr/wrrr/wrrrreset value dbieniso fcdt 00000000 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x12
C8051F326/7 114rev. 0.5 12.13.controlling endpoint1 out endpoint1 out is managed via usb registers eoutcsrl and eoutcsrh. it can be used for interrupt, bulk, or isochronous transfers. isochronous (iso) mode is enabled by writing 1 to the iso bit in register eoutcsrh. bulk and interrupt transfers are handled identically by hardware. an endpoint1 out interrupt may be generated by the following: 1.hardware sets the oprdy bit (eincsrl.0) to 1 . 2.hardware generates a stall condition. 12.13.1.endpoint1 out interrupt or bulk mode when the iso bit (eoutcsrh.6) is logic 0, endpoint1 operates in bulk or interrupt mode. once it has been configured to operate in bulk/interrupt out mode (typically following an endpoint0 set_interface command), hardware will set the oprdy bit (eoutcsrl.0) to 1 and generate an interrupt upon reception of an out token and data packet. the number of bytes in the current out data packet (the packet ready to be unloaded from the fifo) is given in the eoutcnth and eoutcntl reg- isters. in response to this interrupt, firmware should unload the data packet from the out fifo and reset the oprdy bit to 0 . a bulk or interrupt pipe can be shut down (or halted) by writing 1 to the sdstl bit (eoutcsrl.5). while sdstl= 1 , hardware will respond to all out requests with a stall condition. each time hardware gen- erates a stall condition, an interrupt will be generated and the ststl bit (eoutcsrl.6) set to 1 . the ststl bit must be reset to 0 by firmware. hardware will automatically set oprdy when a packet is ready in the out fifo. note that if double buff- ering is enabled for endpoint1, it is possible for two packets to be ready in the out fifo at a time. in this case, hardware will set oprdy to 1 immediately after firmware unloads the first packet and resets oprdy to 0 . a second interrupt will be generated in this case. 12.13.2.endpoint1 out isochronous mode when the iso bit (eoutcsrh.6) is set to 1 , endpoint1 operates in isochronous (iso) mode. once it has been configured for iso out mode, the host will send exactly one data per usb frame; the location of the data packet within each frame may vary, however. because of this, it is recommended that double buffer- ing be enabled when endpoint1 is used in isochronous mode. each time a data packet is received, hardware will load the received data packet into the endpoint fifo, set the oprdy bit (eoutcsrl.0) to 1 , and generate an interrupt (if enabled). firmware would typically use this interrupt to unload the data packet from the endpoint fifo and reset the oprdy bit to 0 . if a data packet is received when there is no room in the endpoint fifo, an interrupt will be generated and the ovrun bit (eoutcsrl.2) set to 1 . if usb0 receives an iso data packet with a crc error, the data packet will be loaded into the endpoint fifo, oprdy will be set to 1 , an interrupt (if enabled) will be gen- erated, and the dataerr bit (eoutcsrl.3) will be set to 1 . software should check the dataerr bit each time a data packet is unloaded from an iso out endpoint fifo.
rev. 0.5115 C8051F326/7 usb register definition12.21.eoutcsrl: usb0 out endpoint control low byte bit7:clrdt: clear data toggle write: software should write 1 to this bit to reset the out endpoint data toggle to 0 . read: this bit always reads 0 . bit6:ststl: sent stall hardware sets this bit to 1 when a stall handshake signal is transmitted. this flag must be cleared by software. bit5:sdstl: send stall software should write 1 to this bit to generate a stall handshake. software should write 0 to this bit to terminate the stall signal. this bit has no effect in iso mode. bit4:flush: fifo flush writing a 1 to this bit flushes the next packet to be read from the out endpoint fifo. the fifo pointer is reset and the oprdy bit is cleared. if the fifo contains multiple packets, software must write 1 to flush for each packet. hardware resets the flush bit to 0 when the fifo flush is complete. bit3:daterr: data error in iso mode, this bit is set by hardware if a received packet has a crc or bit-stuffing error. it is cleared when software clears oprdy. this bit is only valid in iso mode. bit2:ovrun: data overrun this bit is set by hardware when an incoming data packet cannot be loaded into the out endpoint fifo. this bit is only valid in iso mode, and must be cleared by software. 0: no data overrun. 1: a data packet was lost because of a full fifo since this flag was last cleared. bit1:fifoful: out fifo full this bit indicates the contents of the out fifo. if double buffering is enabled for the end- point (dbien = 1 ), the fifo is full when the fifo contains two packets. if dbien = 0 , the fifo is full when the fifo contains one packet. 0: out endpoint fifo is not full. 1: out endpoint fifo is full. bit0:oprdy: out packet ready hardware sets this bit to 1 and generates an interrupt when a data packet is available. soft- ware should clear this bit after each data packet is unloaded from the out endpoint fifo. wr/wr/wr/wrr/wrr/wreset value clrdtststlsdstlflushdaterrovrunfifofuloprdy00000000 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x14
C8051F326/7 116rev. 0.5 usb register definition12.22.eoutcsrh: usb0 out endpoint control high byte usb register definition12.23.eoutcntl: usb0 out endpoint count low usb register definition12.24.eoutcnth: usb0 out endpoint count high bit7:dboen: double-buffer enable 0: double-buffering disabled for the selected out endpoint. 1: double-buffering enabled for the selected out endpoint. bit6:iso: isochronous transfer enable this bit enables/disables isochronous transfers on the current endpoint. 0: endpoint configured for bulk/interrupt transfers. 1: endpoint configured for isochronous transfers. bits5 C 0:unused. read = 000000b; write = don t care. r/wr/wr/wr/wrrrrreset value dboeniso 00000000 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x15 bits7 C 0:eocl: out endpoint count low byte eocl holds the lower 8-bits of the 10-bit number of data bytes in the last received packet in the current out endpoint fifo. this number is only valid while oprdy = 1 . rrrrrrrrreset value eocl00000000 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x16 bits7 C 2:unused. read = 00000. write = don t care. bits1 C 0:eoch: out endpoint count high byte eoch holds the upper 2-bits of the 10-bit number of data bytes in the last received packet in the current out endpoint fifo. this number is only valid while oprdy = 1 . rrrrrrrrreset value e0ch00000000 bit7bit6bit5bit4bit3bit2bit1bit0usb address: 0x17
rev. 0.5117 C8051F326/7 table12.4.usb transceiver electrical characteristics vdd = 3.0 to 3.6 v, C 40 to +85 c unless otherwise specified. parameterssymbolconditionsmintypmaxunits transmitter output high voltage v oh 2.8 v output low voltage v ol 0.8v output crossover point v crs 1.3 2.0v output impedance z drv driving high driving low 38 38 pullup resistance r pu full speed (d+ pullup) low speed (d C pullup) 1.4251.51.575 k output rise time t r low speed full speed 75 4 300 20 ns output fall time t f low speed full speed 75 4 300 20 ns receiver differential input sen- sitivity v di | (d+) C (d C ) |0.2 v differential input com- mon mode range v cm 0.8 2.5v input leakage current i l pullups disabled <1.0 a note: refer to the usb specification for timing diagrams and symbol definitions.
C8051F326/7 118rev. 0.5 n otes :
rev. 0.5119 C8051F326/7 13.uart0 uart0 is an asynchronous, full duplex serial port offering a variety of data formatting options. a dedicated baud rate generator with a 16-bit timer and selectable prescaler is included, which can generate a wide range of baud rates (details in section 13.1.baud rate generator on page120 ). a received data fifo allows uart0 to receive up to three data bytes before data is lost and an overflow occurs. uart0 has six associated sfrs. three are used for the baud rate generator (sbcon0, sbrlh0, and sbrll0), two are used for data formatting, control, and status functions (scon0, smod0), and one is used to send and receive data (sbuf0). the single sbuf0 location provides access to both transmit and receive registers. writes to sbuf0 always access the transmit register. reads of sbuf0 always access the buffered receive register; it is not possible to read data from the transmit register. with uart0 interrupts enabled, an interrupt is generated each time a transmit is completed (ti0 is set in scon0), or a data byte has been received (ri0 is set in scon0). the uart0 interrupt flags are not cleared by hardware when the cpu vectors to the interrupt service routine. they must be cleared manually by software, allowing software to determine the cause of the uart0 interrupt (transmit complete or receive complete). if additional bytes are available in the receive fifo, the ri0 bit cannot be cleared by software. figure 13.1. uart0 block diagram sbuf0 rx fifo (3 deep) tx logic rx logic write to sbuf0 read of sbuf0 tx0 rx0 smod0 m c e 0 s 0 p t 1 s 0 p t 0 p e 0 s 0 d l 1 s 0 d l 0 x b e 0 s b l 0 data formatting scon0 o v r 0 p e r r 0 r e n 0 t b x 0 r b x 0 t i 0 r i 0 control / status uart0 interrupt timer (16-bit) pre-scaler (1, 4, 12, 48) sysclk sbrlh0 sbrll0 overflow sbcon0 s b 0 c l k s b 0 r u n s b 0 p s 1 s b 0 p s 0 en baud rate generator usbclk
C8051F326/7 120rev. 0.5 13.1.baud rate generator the uart0 baud rate is generated by a dedicated 16-bit timer which runs from either the controller s core clock (sysclk) or the usb clock (usbclk), and has prescaler options of 1, 4, 12, or 48. the timer and prescaler options combined allow for a wide selection of baud rates over many clock frequencies. the baud rate generator is configured using three registers: sbcon0, sbrlh0, and sbrll0. the uart0 baud rate generator control register (sbcon0, sfr definition 13.4) enables or disables the baud rate generator, selects the clock source for the baud rate generator, and selects the prescaler value for the timer. the baud rate generator must be enabled for uart0 to function. registers sbrlh0 and sbrll0 contain a 16-bit reload value for the dedicated 16-bit timer. the internal timer counts up from the reload value on every clock tick. on timer overflows (0xffff to 0x0000), the timer is reloaded. the baud rate for uart0 is defined in equation13.1, where brgclock is the baud rate generator s selected clock source. for reliable uart operation, it is recommended that the uart baud rate is not configured for baud rates faster than sysclk/16. equation13.1.uart0 baud rate a quick reference for typical baud rates and clock frequencies is given in table13.1. baud rate brg clock 65536(sbrlh0:sbrll0) C --------------------------------------------------------------------------- 1 2 -- - 1 prescaler ---------------------- =
rev. 0.5121 C8051F326/7 table13.1.baud rate generator settings for standard baud rates target baud rate (bps) actual baud rate (bps) baud rate error oscillator divide factor sb1ps[1:0] (prescaler bits) reload value in sbrlh1:sbrll1 b r g c l o c k = 1 2 m h z 2304002307690.16%52110xffe6 1152001153850.16%104110xffcc 57600576920.16%208110xff98 28800288460.16%416110xff30 14400143880.08%834110xfe5f 960096000.0%1250110xfd8f 240024000.0%5000110xf63c 120012000.0%10000110xec78 b r g c l o c k = 2 4 m h z 2304002307690.16%104110xffcc 1152001153850.16%208110xff98 57600576920.16%416110xff30 28800287770.08%834110xfe5f 14400144060.04%1666110xfcbf 960096000.0%2500110xfb1e 240024000.0%10000110xec78 120012000.0%20000110xd8f0 b r g c l o c k = 4 8 m h z 2304002307690.16%208110xff98 1152001153850.16%416110xff30 57600575540.08%834110xfe5f 28800288120.04%1666110xfcbf 14400143970.02%3334110xf97d 960096000.0%5000110xf63c 240024000.0%20000110xd8f0 120012000.0%40000110xb1e0
C8051F326/7 122rev. 0.5 13.2.data format uart0 has a number of available options for data formatting. data transfers begin with a start bit (logic low), followed by the data bits (sent lsb-first), a parity or extra bit (if selected), and end with one or two stop bits (logic high). the data length is variable between 5 and 8 bits. a parity bit can be appended to the data, and automatically generated and detected by hardware for even, odd, mark, or space parity. the stop bit length is selectable between 1 and 2 bit times, and a multi-processor communication mode is available for implementing networked uart buses. all of the data formatting options can be configured using the smod0 register, shown in sfr definition 13.2.figure13.2 shows the timing for a uart0 transaction without parity or an extra bit enabled. figure13.3 shows the timing for a uart0 transaction with parity enabled (pe0=1). figure13.4 is an example of a uart0 transaction when the extra bit is enabled (xbe0=1). note that the extra bit feature is not available when parity is enabled, and the second stop bit is only an option for data lengths of 6, 7, or 8 bits. figure 13.2. uart0 timing without parity or extra bit figure 13.3. uart0 timing with parity figure 13.4. uart0 timing with extra bit d 1 d 0 d n-2 d n-1 start bit mark stop bit 1 bit times space n bits; n = 5, 6, 7, or 8 stop bit 2 optional (6,7,8 bit data) d 1 d 0 d n-2 d n-1 parity start bit mark stop bit 1 bit times space n bits; n = 5, 6, 7, or 8 stop bit 2 optional (6,7,8 bit data) d 1 d 0 d n-2 d n-1 extra start bit mark stop bit 1 bit times space n bits; n = 5, 6, 7, or 8 stop bit 2 optional (6,7,8 bit data)
rev. 0.5123 C8051F326/7 13.3.configuration and operation uart0 provides standard asynchronous, full duplex communication. it can operate in a point-to-point serial communications application, or as a node on a multi-processor serial interface. to operate in a point-to-point application, where there are only two devices on the serial bus, the mce0 bit in smod0 should be cleared to 0 . for operation as part of a multi-processor communications bus, the mce0 and xbe0 bits should both be set to 1 . in both types of applications, data is transmitted from the microcontrol- ler on the tx0 pin, and received on the rx0 pin. the tx0 and rx0 pins are configured using the crossbar and the port i/o registers, as detailed in section 11.port input/output on page81 . in typical uart communications, the transmit (tx) output of one device is connected to the receive (rx) input of the other device, either directly or through a bus transceiver, as shown in figure13.5. figure 13.5. typical uart interconnect diagram 13.3.1.data transmission data transmission begins when software writes a data byte to the sbuf0 register. the ti0 transmit inter- rupt flag (scon0.1) will be set at the end of any transmission (the beginning of the stop-bit time). if enabled, an interrupt will occur when ti0 is set. if the extra bit function is enabled (xbe0= 1 ) and the parity function is disabled (pe0 = 0 ), the value of the tbx0 (scon0.3) bit will be sent in the extra bit position. when the parity function is enabled (pe0 = 1 ), hardware will generate the parity bit according to the selected parity type (selected with s0pt[1:0]), and append it to the data field. note: when parity is enabled, the extra bit function is not available. 13.3.2.data reception data reception can begin any time after the ren0 receive enable bit (scon0.4) is set to logic1. after the stop bit is received, the data byte will be stored in the receive fifo if the following conditions are met: the receive fifo (3 bytes deep) must not be full, and the stop bit(s) must be logic1. in the event that the receive fifo is full, the incoming byte will be lost, and a receive fifo overrun error will be generated (ovr0 in register scon0 will be set to logic1). if the stop bit(s) were logic0, the incoming data will not be stored in the receive fifo. if the reception conditions are met, the data is stored in the receive fifo, and the ri0 flag will be set. note: when mce0 = 1 , ri0 will only be set if the extra bit was equal to 1 . data can be read from the receive fifo by reading the sbuf0 register. the sbuf0 register represents the oldest byte in the fifo. after sbuf0 is read, the next byte in the fifo is loaded into sbuf0, and space is made available in the fifo for another incoming byte. if enabled, an interrupt will occur when ri0 is set. if the extra bit function is enabled (xbe0 = 1 ) and the parity function is disabled (pe0 = 0 ), the extra bit for the oldest byte in the fifo can be read from the rbx0 bit (scon0.2). if the extra bit function is not or rs-232 c8051fxxx rs-232 level translator tx rx c8051fxxx rx tx mcu rx tx pc com port
C8051F326/7 124rev. 0.5 enabled, the value of the stop bit for the oldest fifo byte will be presented in rbx0. when the parity func- tion is enabled (pe0 = 1 ), hardware will check the received parity bit against the selected parity type (selected with s0pt[1:0]) when receiving data. if a byte with parity error is received, the perr0 flag will be set to 1 . this flag must be cleared by software. note: when parity is enabled, the extra bit function is not available. 13.3.3.multiprocessor communications uart0 supports multiprocessor communication between a master processor and one or more slave pro- cessors by special use of the extra data bit. when a master processor wants to transmit to one or more slaves, it first sends an address byte to select the target(s). an address byte differs from a data byte in that its extra bit is logic1; in a data byte, the extra bit is always set to logic0. setting the mce0 bit (smod0.7) of a slave processor configures its uart such that when a stop bit is received, the uart will generate an interrupt only if the extra bit is logic1 (rbx0 = 1) signifying an address byte has been received. in the uart interrupt handler, software will compare the received address with the slave's own assigned address. if the addresses match, the slave will clear its mce0 bit to enable interrupts on the reception of the following data byte(s). slaves that weren't addressed leave their mce0 bits set and do not generate interrupts on the reception of the following data bytes, thereby ignoring the data. once the entire message is received, the addressed slave resets its mce0 bit to ignore all trans- missions until it receives the next address byte. multiple addresses can be assigned to a single slave and/or a single address can be assigned to multiple slaves, thereby enabling "broadcast" transmissions to more than one slave simultaneously. the master processor can be configured to receive all transmissions or a protocol can be implemented such that the master/slave role is temporarily reversed to enable half-duplex transmission between the original master and slave(s). figure 13.6. uart multi-processor mode interconnect diagram master device slave device tx rxrxtx slave device rxtx slave device rxtx v+
rev. 0.5125 C8051F326/7 sfr definition13.1.scon0: uart0 control bit7:ovr0: receive fifo overrun flag. this bit is used to indicate a receive fifo overrun condition. 0: receive fifo overrun has not occurred. 1: receive fifo overrun has occurred (an incoming character was discarded due to a full fifo). this bit must be cleared to 0 by software. bit6:perr0: parity error flag. when parity is enabled, this bit is used to indicate that a parity error has occurred. it is set to 1 when the parity of the oldest byte in the fifo does not match the selected parity type. 0: parity error has not occurred. 1: parity error has occurred. this bit must be cleared to 0 by software. bit5:unused. read = 1b; write = don t care. bit4:ren0: receive enable. this bit enables/disables the uart receiver. when disabled, bytes can still be read from the receive fifo. 0: uart0 reception disabled. 1: uart0 reception enabled. bit3:tbx0: extra transmission bit. the logic level of this bit will be assigned to the extra transmission bit when xbe0 is set to 1 . this bit is not used when parity is enabled. bit2:rbx0: extra receive bit. rbx0 is assigned the value of the extra bit when xbe0 is set to 1 . if xbe0 is cleared to 0 , rbx0 will be assigned the logic level of the first stop bit. this bit is not valid when parity is enabled. bit1:ti0: transmit interrupt flag. set to a 1 by hardware after data has been transmitted, at the beginning of the stop bit. when the uart0 interrupt is enabled, setting this bit causes the cpu to vector to the uart0 interrupt service routine. this bit must be cleared manually by software. bit0:ri0: receive interrupt flag. set to 1 by hardware when a byte of data has been received by uart0 (set at the stop bit sampling time). when the uart0 interrupt is enabled, setting this bit to 1 causes the cpu to vector to the uart0 interrupt service routine. this bit must be cleared manually by soft- ware. r/wr/wrr/wr/wr/wr/wr/wreset value ovr0perr0 ren0tbx0rbx0ti0ri000100000 bit7bit6bit5bit4bit3bit2bit1bit0 bit addressable sfr address: 0x98
C8051F326/7 126rev. 0.5 sfr definition13.2.smod0: uart0 mode bit7:mce0: multiprocessor communication enable. 0: ri will be activated if stop bit(s) are 1 . 1: ri will be activated if stop bit(s) and extra bit are 1 (extra bit must be enabled using xbe0). note: this function is not available when hardware parity is enabled. bits6 C 5:s0pt[1:0]: parity type. 00: odd 01: even 10: mark 11: space bit4:pe0: parity enable. this bit activates hardware parity generation and checking. the parity type is selected by bits s0pt1-0 when parity is enabled. 0: hardware parity is disabled. 1: hardware parity is enabled. bits3 C 2:s0dl[1:0]: data length. 00: 5-bit data 01: 6-bit data 10: 7-bit data 11: 8-bit data bit1:xbe0: extra bit enable when enabled, the value of tbx0 will be appended to the data field. 0: extra bit disabled. 1: extra bit enabled. bit0:sbl0: stop bit length 0: short - stop bit is active for one bit time (all data field lengths). 1: long - stop bit is active for two bit times (data length = 6, 7, or 8 bits). r/wr/wr/wr/wr/wr/wr/wr/wreset value mce0s0pt1s0pt0pe0s0dl1s0dl0xbe0sbl000001100 bit7bit6bit5bit4bit3bit2bit1bit0 bit addressable sfr address: 0x9a
rev. 0.5127 C8051F326/7 sfr definition13.3.sbuf0: uart0 data buffer sfr definition13.4.sbcon0: uart0 baud rate generator control bits7 C 0:sbuf0[7:0]: serial data buffer bits 7 C 0 (msb C lsb) this sfr is used to both send data from the uart and to read received data from the uart0 receive fifo. write: when data is written to sbuf0, it goes to the transmit shift register and is held for serial transmission. writing a byte to sbuf0 initiates the transmission. read: reading sbuf0 retrieves data from the receive fifo. when read, the oldest byte in the receive fifo is returned, and removed from the fifo. up to three bytes may be held in the fifo. if there are additional bytes available in the fifo, the ri0 bit will remain at logic 1 , even after being cleared by software. r/wr/wr/wr/wr/wr/wr/wr/wreset value 00000000 bit7bit6bit5bit4bit3bit2bit1bit0 sfr address: 0x99 bit7:sb0clk: baud rate generator clock source. 0: sysclk is used as baud rate generator clock source. 1: usbclk is used as baud rate generator clock source. bit6:sb0run: baud rate generator enable. 0: baud rate generator is disabled. uart0 will not function. 1: baud rate generator is enabled. bits5 C 2:reserved: read = 0000b; must write 0000b. bits1 C 0:sb0ps[1:0]: baud rate prescaler select. 00: prescaler = 12 01: prescaler = 4 10: prescaler = 48 11: prescaler = 1 r/wr/wr/wr/wr/wr/wr/wr/wreset value sb0clksb0runreservedreservedreservedreservedsb0ps1sb0ps000000000 bit7bit6bit5bit4bit3bit2bit1bit0 bit addressable sfr address: 0x91
C8051F326/7 128rev. 0.5 sfr definition13.5.sbrlh0: uart0 baud rate generator high byte sfr definition13.6.sbrll0: uart0 baud rate generator low byte bits7-0:sbrlh0[7:0]: high byte of reload value for uart0 baud rate generator. r/wr/wr/wr/wr/wr/wr/wr/wreset value 00000000 bit7bit6bit5bit4bit3bit2bit1bit0 sfr address: 0x94 bits7-0:sbrll0[7:0]: low byte of reload value for uart0 baud rate generator. r/wr/wr/wr/wr/wr/wr/wr/wreset value 00000000 bit7bit6bit5bit4bit3bit2bit1bit0 sfr address: 0x93
rev. 0.5129 C8051F326/7 14.timers each mcu includes two 16-bit timers compatible with those found in the standard 8051. these timers can be used to measure time intervals and generate periodic interrupt requests. timer0 and timer1 are nearly identical and have four primary modes of operation. timers 0 and 1 may be clocked by one of five sources, determined by the timer mode select bits (t1m- t0m) and the clock scale bits (sca1-sca0). the clock scale bits define a pre-scaled clock from which timer0 and/or timer1 may be clocked (see figure14.3 for pre-scaled clock selection). timer0/1 may then be configured to use this pre-scaled clock signal or the system clock. timers 0 and 1 have a gate mode which allows the timer to run only when an external interrupt is active (/int0 for timer 0 and /int1 for timer 1. this mode facilitates pulse width measurements on input on p0.2 (timer 0) and low frequency oscillator calibration when used with timer 1. 14.1.timer 0 and timer 1 operating modes each timer is implemented as a 16-bit register accessed as two separate bytes: a low byte (tl0 or tl1) and a high byte (th0 or th1). the timer control register (tcon) is used to enable timer 0 and timer 1 as well as indicate status. timer 0 interrupts can be enabled by setting the et0 bit in the ie register ( section 8.3.5.interrupt register descriptions on page61 ); timer 1 interrupts can be enabled by setting the et1 bit in the ie register ( section 8.3.5 ). both timers operate in one of four primary modes selected by set- ting the mode select bits t1m1-t0m0 in the timer mode register (tmod). each timer can be configured independently. each operating mode is described below. timer 0 and timer 1 modes: 13-bit timer 16-bit timer 8-bit timer with auto-reload two 8-bit timers (timer 0 only)
C8051F326/7 130rev. 0.5 14.1.1.mode 0: 13-bit timer timer 0 and timer 1 operate as 13-bit timers in mode 0. the following describes the configuration and operation of timer 0. however, both timers operate identically, and timer 1 is configured in the same man- ner as described for timer 0. the th0 register holds the eight msbs of the 13-bit timer. tl0 holds the five lsbs in bit positions tl0.4- tl0.0. the three upper bits of tl0 (tl0.7-tl0.5) are indeterminate and should be masked out or ignored when reading. as the 13-bit timer register increments and overflows from 0x1fff (all ones) to 0x0000, the timer overflow flag tf0 (tcon.5) is set and an interrupt will occur if timer 0 interrupts are enabled. setting the tr0 bit (tcon.4) enables the timer when either gate0 (tmod.3) is logic 0 or gate0 is logic 1 and the input signal /int0 is active. setting gate0 to logic 1 allows the timer to be controlled by the external input signal /int0, facilitating pulse width measurements. when gate0 is set to logic 1, the /int0 input pin is p0.2. setting tr0 does not force the timer to reset. the timer registers should be loaded with the desired initial value before the timer is enabled. tl1 and th1 form the 13-bit register for timer 1 in the same manner as described above for tl0 and th0. timer 1 is configured and controlled using the relevant tcon and tmod bits just as with timer 0. the input signal /int1 is used with timer 1. see section 8.3.2.external interrupts on page59 for a complete description of /int0 and /int1. figure 14.1. t0 mode 0 block diagram tr0gate0/int0timer 0xxdisabled 10xenabled 110 (p0.2 high)disabled 111 (p0.2 low)enabled x = don't care tclk tl0 (5 bits) th0 (8 bits) t c o n tf0 tr0 tr1 tf1 ie1 it1 ie0 it0 interrupt tr0 0 1 sysclk pre-scaled clock ckcon s c a 0 s c a 1 t 0 m t 1 m tmod t 1 m 1 t 1 m 0 c / t 1 g a t e 1 g a t e 0 c / t 0 t 0 m 1 t 0 m 0 gate0 /int0
rev. 0.5131 C8051F326/7 14.1.2.mode 1: 16-bit timer mode 1 operation is the same as mode 0, except that the timer registers use all 16 bits. the timers are enabled and configured in mode 1 in the same manner as for mode 0. 14.1.3.mode 2: 8-bit timer with auto-reload mode 2 configures timer 0 and timer 1 to operate as 8-bit timers with automatic reload of the start value. tl0 holds the count and th0 holds the reload value. when the counter in tl0 overflows from all ones to 0x00, the timer overflow flag tf0 (tcon.5) is set and the counter in tl0 is reloaded from th0. if timer 0 interrupts are enabled, an interrupt will occur when the tf0 flag is set. the reload value in th0 is not changed. tl0 must be initialized to the desired value before enabling the timer for the first count to be cor- rect. when in mode 2, timer 1 operates identically to timer 0. both timers are enabled and configured in mode 2 in the same manner as mode 0. setting the tr0 bit (tcon.4) enables the timer when gate0 (tmod.3) is logic 0 or when gate0 is logic 1 and the input sig- nal /int0 is active (see section 8.3.2.external interrupts on page59 for details on the external input signals /int0 and /int1). figure 14.2. t0 mode 2 block diagram tclk t c o n tf0 tr0 tr1 tf1 ie1 it1 ie0 it0 interrupt tl0 (8 bits) reload th0 (8 bits) tr0 0 1 sysclk pre-scaled clock ckcon s c a 0 s c a 1 t 0 m t 1 m tmod t 1 m 1 t 1 m 0 c / t 1 g a t e 1 g a t e 0 c / t 0 t 0 m 1 t 0 m 0 gate0 /int0
C8051F326/7 132rev. 0.5 14.1.4.mode 3: two 8-bit timers (timer 0 only) in mode 3, timer 0 is configured as two separate 8-bit timers held in tl0 and th0. the counter in tl0 is controlled using the timer 0 control/status bits in tcon and tmod: tr0, c/t0, gate0 and tf0. tl0 can use either the system clock or an external input signal as its timebase. the th0 register is restricted to a timer function sourced by the system clock or prescaled clock. th0 is enabled using the timer 1 run con- trol bit tr1. th0 sets the timer 1 overflow flag tf1 on overflow and thus controls the timer 1 interrupt. timer 1 is inactive in mode 3. when timer 0 is operating in mode 3, timer 1 can be operated in modes 0, 1 or 2, but cannot set the tf1 flag and generate an interrupt. however, the timer 1 overflow can be used to generate baud rates for the uart. while timer 0 is operating in mode 3, timer 1 run control is handled through its mode settings. to run timer 1 while timer 0 is in mode 3, set the timer 1 mode as 0, 1, or 2. to disable timer 1, configure it for mode 3. figure 14.3. t0 mode 3 block diagram tl0 (8 bits) t c o n tf0 tr0 tr1 tf1 ie1 it1 ie0 it0 interrupt interrupt tr1 th0 (8 bits) tr0 0 1 sysclk pre-scaled clock ckcon s c a 0 s c a 1 t 0 m t 1 m tmod t 1 m 1 t 1 m 0 c / t 1 g a t e 1 g a t e 0 c / t 0 t 0 m 1 t 0 m 0 gate0 /int0
rev. 0.5133 C8051F326/7 sfr definition14.1.tcon: timer control bit7:tf1: timer 1 overflow flag. set by hardware when timer 1 overflows. this flag can be cleared by software but is auto- matically cleared when the cpu vectors to the timer 1 interrupt service routine. 0: no timer 1 overflow detected. 1: timer 1 has overflowed. bit6:tr1: timer 1 run control. 0: timer 1 disabled. 1: timer 1 enabled. bit5:tf0: timer 0 overflow flag. set by hardware when timer 0 overflows. this flag can be cleared by software but is auto- matically cleared when the cpu vectors to the timer 0 interrupt service routine. 0: no timer 0 overflow detected. 1: timer 0 has overflowed. bit4:tr0: timer 0 run control. 0: timer 0 disabled. 1: timer 0 enabled. bit3:ie1: external interrupt 1. this flag is set by hardware when an edge/level of type defined by it1 is detected. it can be cleared by software but is automatically cleared when the cpu vectors to the external inter- rupt 1 service routine if it1 = 1. when it1 = 0, this flag is set to 1 when /int1 is active. bit2:it1: interrupt 1 type select. this bit selects whether the configured /int1 interrupt will be edge or level sensitive. 0: /int1 is level triggered. 1: /int1 is edge triggered. bit1:ie0: external interrupt 0. this flag is set by hardware when an edge/level of type defined by it0 is detected. it can be cleared by software but is automatically cleared when the cpu vectors to the external inter- rupt 0 service routine if it0 = 1. when it0 = 0, this flag is set to 1 when /int0 is active. bit0:it0: interrupt 0 type select. this bit selects whether the configured /int0 interrupt will be edge or level sensitive. 0: /int0 is level triggered. 1: /int0 is edge triggered. r/wr/wr/wr/wr/wr/wr/wr/wreset value tf1tr1tf0tr0ie1it1ie0it000001010 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: (bit addressable) 0x88
C8051F326/7 134rev. 0.5 sfr definition14.2.tmod: timer mode bit7:gate1: timer 1 gate control. 0: timer 1 enabled when tr1 = 1 irrespective of /int1 logic level. /int1 is activated when the internal oscillator resumes from a suspended state. 1: timer 1 enabled only when tr1 = 1 and /int1 is active. /int1 is activated every 2 low frequency oscillator clock cycles. this is a rate of 40khz. bit6:reserved. read = 0b. must write 0b. bits5 C 4:t1m1-t1m0: timer 1 mode select. these bits select the timer 1 operation mode. bit3:gate0: timer 0 gate control. 0: timer 0 enabled when tr0 = 1 irrespective of /int0 logic level. /int0 input pin is p0.0. 1: timer 0 enabled only when tr0 = 1 and /int0 is active. /int0 input pin is p0.2. bit2:reserved. read = 0b. must write 0b. bits1 C 0:t0m1-t0m0: timer 0 mode select. these bits select the timer 0 operation mode. r/wr/wr/wr/wr/wr/wr/wr/wreset value gate1reservedt1m1t1m0gate0reservedt0m1t0m000000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0x89 t1m1t1m0mode 00mode 0: 13-bit timer 01mode 1: 16-bit timer 10mode 2: 8-bit timer with auto-reload 11mode 3: timer 1 inactive t0m1t0m0mode 00mode 0: 13-bit timer 01mode 1: 16-bit timer 10mode 2: 8-bit timer with auto-reload 11mode 3: two 8-bit timers
rev. 0.5135 C8051F326/7 sfr definition14.3.ckcon: clock control bit7 C 4:unused. read = 0b. write = don t care. bit3:t1m: timer 1 clock select. this select the clock source supplied to timer 1. 0: timer 1 uses the clock defined by the prescale bits, sca1-sca0. 1: timer 1 uses the system clock. bit2:t0m: timer 0 clock select. this bit selects the clock source supplied to timer 0. 0: timer 0 uses the clock defined by the prescale bits, sca1-sca0. 1: timer 0 uses the system clock. bits1 C 0:sca1-sca0: timer 0/1 prescale bits. these bits control the division of the clock supplied to timer 0 and/or timer 1 if configured to use prescaled clock inputs. r/wr/wr/wr/wr/wr/wr/wr/wreset value t1mt0msca1sca000000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0x8e sca1sca0prescaled clock 00system clock divided by 12 01system clock divided by 4 10system clock divided by 48 11external clock divided by 8 note: external clock divided by 8 is synchronized with the system clock.
C8051F326/7 136rev. 0.5 sfr definition14.4.tl0: timer 0 low byte sfr definition14.5.tl1: timer 1 low byte sfr definition14.6.th0: timer 0 high byte sfr definition14.7.th1: timer 1 high byte bits 7 C 0:tl0: timer 0 low byte. the tl0 register is the low byte of the 16-bit timer 0. r/wr/wr/wr/wr/wr/wr/wr/wreset value 00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0x8a bits 7 C 0:tl1: timer 1 low byte. the tl1 register is the low byte of the 16-bit timer 1. r/wr/wr/wr/wr/wr/wr/wr/wreset value 00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0x8b bits 7 C 0:th0: timer 0 high byte. the th0 register is the high byte of the 16-bit timer 0. r/wr/wr/wr/wr/wr/wr/wr/wreset value 00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0x8c bits 7 C 0:th1: timer 1 high byte. the th1 register is the high byte of the 16-bit timer 1. r/wr/wr/wr/wr/wr/wr/wr/wreset value 00000000 bit7bit6bit5bit4bit3bit2bit1bit0sfr address: 0x8d
rev. 0.5137 C8051F326/7 15.c2 interface C8051F326/7 devices include an on-chip silicon laboratories 2-wire (c2) debug interface to allow flash programming and in-system debugging with the production part installed in the end application. the c2 interface uses a clock signal (c2ck) and a bi-directional c2 data signal (c2d) to transfer information between the device and a host system. see the c2 interface specification for details on the c2 protocol. 15.1.c2 interface registers the following describes the c2 registers necessary to perform flash programming functions through the c2 interface. all c2 registers are accessed through the c2 interface as described in the c2 interface spec- ification. c2 register definition15.1.c2add: c2 address c2 register definition15.2.deviceid: c2 device id bits7 C 0:the c2add register is accessed via the c2 interface to select the target data register for c2 data read and data write commands. reset value 00000000 bit7bit6bit5bit4bit3bit2bit1bit0 addressdescription 0x00selects the device id register for data read instructions 0x01selects the revision id register for data read instructions 0x02 selects the c2 flash programming control register for data read/write instructions 0xb4 selects the c2 flash programming data register for data read/write instructions this read-only register returns the 8-bit device id: 0x0d (C8051F326/7). reset value 00001001 bit7bit6bit5bit4bit3bit2bit1bit0
C8051F326/7 138rev. 0.5 c2 register definition15.3.revid: c2 revision id c2 register definition15.4.fpctl: c2 flash programming control c2 register definition15.5.fpdat: c2 flash programming data this read-only register returns the 8-bit revision id: 0x01 (revision b). reset value 00000000 bit7bit6bit5bit4bit3bit2bit1bit0 bits7 C 0fpctl: flash programming control register. this register is used to enable flash programming via the c2 interface. to enable c2 flash programming, the following codes must be written in order: 0x02, 0x01. note that once c2 flash programming is enabled, a system reset must be issued to resume normal operation. reset value 00000000 bit7bit6bit5bit4bit3bit2bit1bit0 bits7 C 0:fpdat: c2 flash programming data register. this register is used to pass flash commands, addresses, and data during c2 flash accesses. valid commands are listed below. reset value 00000000 bit7bit6bit5bit4bit3bit2bit1bit0 codecommand 0x06flash block read 0x07flash block write 0x08flash page erase 0x03device erase
rev. 0.5139 C8051F326/7 15.2.c2 pin sharing the c2 protocol allows the c2 pins to be shared with user functions so that in-system debugging and flash programming may be performed. this is possible because c2 communication is typically performed when the device is in the halt state, where all on-chip peripherals and user software are stalled. in this halted state, the c2 interface can safely borrow the c2ck (/rst) and c2d (p3.0) pins. in most applica- tions, external resistors are required to isolate c2 interface traffic from the user application. a typical isola- tion configuration is shown in figure15.1. figure 15.1. typical c2 pin sharing the configuration in figure15.1 assumes the following: 1.the user input (b) cannot change state while the target device is halted. 2.the /rst pin on the target device is used as an input only. additional resistors may be necessary depending on the specific application. c2d c2ck /reset (a) input (b) output (c) c2 interface master C8051F326/7
C8051F326/7 140rev. 0.5 c ontact i nformation silicon laboratories inc. 4635 boston lane austin, tx 78735 tel: 1+(512) 416-8500 fax: 1+(512) 416-9669 toll free: 1+(877) 444-3032 email: mcuinfo@silabs.com internet: www.silabs.com silicon laboratories and silicon labs are trademarks of silicon laboratories inc. other products or brandnames mentioned herein are trademarks or registered trademarks of their respective holders the information in this document is believed to be accurate in all respects at the time of publication but is subject to change without notice. silicon laboratories assumes no responsibility for errors and omissions, and disclaims responsibility for any consequences resulting from the use of information included herein. additionally, silicon laboratories assumes no responsibility for the function- ing of undescribed features or parameters. silicon laboratories reserves the right to make changes without further notice. silicon laboratories makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does silicon laboratories assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. silicon laboratories products are not designed, intended, or authorized for use in applications intended to support or sustain life, or for any other application in which the failure of the silicon laboratories product could create a situation where personal injury or death may occur. should buyer purchase or use silicon laboratories products for any such unintended or unauthorized application, buyer shall indemnify and hold silicon laboratories harmless against all claims and damages.


▲Up To Search▲   

 
Price & Availability of C8051F326

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X